zsh: add jeffreytse/zsh-vi-mode to be -- NORMAL --

add jeffreytse/zsh-vi-mode with sheldon.

history substring search bindings are remapped to work with 'viins' and
'vicmd' (NORMAL) modes of the vi prompt, and J and K mappings in 'vicmd'
mode are added.

fzf loading also had to be reworked using system installation fzf
completions are used. bindings for fzf are broken if loaded
conventionally, therefore a helper function is offered by zsh-vi-mode to
source anything after vi mode is initialized and it is used to source
said completions.

at this occasion FZF_COMPLETION_OPTS et al. have also been reworked a
little to use dracula colorscheme, fd-find instead of find and bat to
auto-colour files.
This commit is contained in:
surtur 2022-03-26 01:20:55 +01:00
parent f14878faab
commit e4a745d5fb
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 23 additions and 3 deletions

@ -16,3 +16,6 @@ github = 'djui/alias-tips'
[plugins.fast-syntax-highlighting]
github = 'zdharma-continuum/fast-syntax-highlighting'
[plugins.zsh-vi-mode]
github = 'jeffreytse/zsh-vi-mode'

23
.zshrc

@ -63,7 +63,7 @@
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
plugins=(asdf fzf git gitignore golang safe-paste systemd terraform lol)
plugins=(asdf git gitignore golang safe-paste systemd terraform lol)
source $ZSH/oh-my-zsh.sh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
@ -78,11 +78,28 @@
# map arrow up/down to control fish-like history substring search and highlighting
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# also map the same keys in 'viins' (INSERT) mode...
bindkey -M viins '^[[A' history-substring-search-up
bindkey -M viins '^[[B' history-substring-search-down
# ...and in 'vicmd' (NORMAL) mode...
bindkey -M vicmd '^[[A' history-substring-search-up
bindkey -M vicmd '^[[B' history-substring-search-down
# ...and as well to K, J, instead of arrow up/down, respectively.
# note these are capital letters, original behaviour of j, k is left unchanged
bindkey -M vicmd 'K' history-substring-search-up
bindkey -M vicmd 'J' history-substring-search-down
HISTORY_SUBSTRING_SEARCH_FUZZY=" "
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git --exclude 'node_modules' ."
export FZF_CTRL_T_COMMAND="fd --follow --full-path --base-directory . --exclude '.git' --exclude 'node_modules' ."
export FZF_ALT_C_COMMAND="fd -H -t d ."
export DISABLE_FZF_AUTO_COMPLETION="true"
# Options to fzf command
FZF_COMPLETION_OPTS='+c -x'
FZF_DEFAULT_OPTS="--height=60% --inline-info --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4"
export FZF_COMPLETION_OPTS='+c -x'
export FZF_DEFAULT_OPTS="--height=60% --inline-info --color=fg:#f8f8f2,bg:#282a36,hl:#bd93f9 --color=fg+:#f8f8f2,bg+:#44475a,hl+:#bd93f9 --color=info:#ffb86c,prompt:#50fa7b,pointer:#ff79c6 --color=marker:#ff79c6,spinner:#ffb86c,header:#6272a4"
export FZF_CTRL_T_OPTS="--preview 'bat --style=numbers --color=always --line-range :200 {}'"
zvm_after_init_commands+=('[ -f /usr/share/fzf/shell/key-bindings.zsh ] && source /usr/share/fzf/shell/key-bindings.zsh')
# User configuration
source ~/.dotenv