From a6bcefd2461800af03cd311cce6500c64f649930 Mon Sep 17 00:00:00 2001 From: Luna Komorebi Date: Fri, 19 Apr 2024 16:37:08 +0200 Subject: [PATCH] fix keybindings --- .zshrc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/.zshrc b/.zshrc index 6153120..d8b40bd 100644 --- a/.zshrc +++ b/.zshrc @@ -74,8 +74,81 @@ if [ -d "$HOME/.zsh-custom" ]; then done fi -bindkey "^[[1;5C" forward-word -bindkey "^[[1;5D" backward-word + +# configure completion +zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' +zstyle ':completion:*' special-dirs true +zstyle ':completion:*' list-colors '' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' +zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w" +zstyle ':completion:*' use-cache yes +zstyle ':completion:*' cache-path "$HOME/.cache/zsh" + +# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/key-bindings.zsh + +# Make sure that the terminal is in application mode when zle is active, since +# only then values from $terminfo are valid +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + zle-line-init() { + echoti smkx + } + zle-line-finish() { + echoti rmkx + } + zle -N zle-line-init + zle -N zle-line-finish +fi + +# Use emacs key bindings +bindkey -e + +# Start typing + [Up-Arrow] - fuzzy find history forward +if [[ -n "${terminfo[kcuu1]}" ]]; then + autoload -U up-line-or-beginning-search + zle -N up-line-or-beginning-search + + bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search +fi +# Start typing + [Down-Arrow] - fuzzy find history backward +if [[ -n "${terminfo[kcud1]}" ]]; then + autoload -U down-line-or-beginning-search + zle -N down-line-or-beginning-search + + bindkey "${terminfo[kcud1]}" down-line-or-beginning-search +fi + +# [Home] - Go to beginning of line +if [[ -n "${terminfo[khome]}" ]]; then + bindkey "${terminfo[khome]}" beginning-of-line +fi +# [End] - Go to end of line +if [[ -n "${terminfo[kend]}" ]]; then + bindkey "${terminfo[kend]}" end-of-line +fi + +# [Shift-Tab] - move through the completion menu backwards +if [[ -n "${terminfo[kcbt]}" ]]; then + bindkey "${terminfo[kcbt]}" reverse-menu-complete +fi + +# [Delete] - delete forward +if [[ -n "${terminfo[kdch1]}" ]]; then + bindkey "${terminfo[kdch1]}" delete-char +else + bindkey "^[[3~" delete-char + bindkey "^[3;5~" delete-char +fi + +# [Ctrl-RightArrow] - move forward one word +bindkey '^[[1;5C' forward-word +# [Ctrl-LeftArrow] - move backward one word +bindkey '^[[1;5D' backward-word + +# Enable Ctrl-x-e to edit command line +autoload -U edit-command-line +zle -N edit-command-line +bindkey '^xe' edit-command-line DISABLE_MAGIC_FUNCTIONS=true source $OTHER/func.zsh