Browse Source

added vi bindings for zsh

Josh Bicking 7 years ago
parent
commit
8ac49c12af
1 changed files with 26 additions and 0 deletions
  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