feat(zsh): add sensible keybinds for navigation, editing, history, completion, and autosuggestions
Improves productivity and usability for both emacs and vi mode users. 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
parent
7d13e6ff1c
commit
bfb508733e
41
.zshrc
41
.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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user