Bladeren bron

added vi bindings for zsh

Josh Bicking 8 jaren geleden
bovenliggende
commit
8ac49c12af
1 gewijzigde bestanden met toevoegingen van 26 en 0 verwijderingen
  1. 26 0
      zshrc

+ 26 - 0
zshrc

@@ -65,6 +65,32 @@ alias emacs='emacs -nw'
 # alias for getting latest file in a folder
 alias latest='ls -t | head -n 1'
 
+# vi bindings
+bindkey -v
+export KEYTIMEOUT=1
+
+bindkey '^P' up-history
+bindkey '^N' down-history
+bindkey '^?' backward-delete-char
+bindkey '^h' backward-delete-char
+bindkey '^w' backward-kill-word
+bindkey '^r' history-incremental-search-backward
+
+function zle-line-init zle-keymap-select {
+    VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}"
+    RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
+    zle reset-prompt
+}
+function zle-line-finish {
+    VIM_PROMPT=""
+    RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
+    zle reset-prompt
+}
+RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1"
+
+zle -N zle-line-init
+zle -N zle-keymap-select
+
 # grml
 if [ ! $ZSH_CUSTOM ]
 then