From bfb508733e71ffa8ab0ed2e38e45d9e36705db8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=BCchler?= Date: Thu, 7 Aug 2025 23:07:35 +0200 Subject: [PATCH] feat(zsh): add sensible keybinds for navigation, editing, history, completion, and autosuggestions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improves productivity and usability for both emacs and vi mode users. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode --- .zshrc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/.zshrc b/.zshrc index 9f702f7..143f022 100644 --- a/.zshrc +++ b/.zshrc @@ -65,6 +65,9 @@ setopt hist_reduce_blanks # Autosuggestions if [ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh + # Accept autosuggestion with Ctrl+F or Right Arrow + bindkey '^F' autosuggest-accept + bindkey '^[[C' autosuggest-accept fi # Syntax highlighting if [ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then @@ -74,6 +77,44 @@ fi fpath+=/usr/share/zsh/site-functions autoload -Uz compinit && compinit +# ===================== +# Sensible keybinds +# ===================== + +# Emacs mode by default (comment out for vi mode) +bindkey -e +# Uncomment below for vi mode +# bindkey -v + +# History search +bindkey '^R' history-incremental-search-backward +bindkey '^S' history-incremental-search-forward + +# Navigation +bindkey '^A' beginning-of-line +bindkey '^E' end-of-line +bindkey '^[b' backward-word +bindkey '^[f' forward-word + +# Editing +bindkey '^U' kill-whole-line +bindkey '^W' backward-kill-word +bindkey '^K' kill-line +bindkey '^Y' yank + +# Completion +bindkey '^I' expand-or-complete +bindkey '^ ' menu-complete + +# fzf keybinds (if fzf is loaded) +if [ -n "$FZF_TMUX" ] || [ -f /usr/share/fzf/key-bindings.zsh ]; then + # Ctrl+T: fzf file search + bindkey '^T' fzf-file-widget + # Ctrl+R: fzf history search (already set above) + # Alt+C: fzf cd widget + bindkey '^[c' fzf-cd-widget +fi + # ===================== # Command-not-found handler (Arch/pkgfile)