Skip to content

Instantly share code, notes, and snippets.

@worldofprasanna
Created March 30, 2018 09:15
Show Gist options
  • Save worldofprasanna/28a57168109bccf148f32dbfae450e03 to your computer and use it in GitHub Desktop.
Save worldofprasanna/28a57168109bccf148f32dbfae450e03 to your computer and use it in GitHub Desktop.
Enable vi mode in command line with indicator for Normal/Insert mode
# Indicate whether user is in Normal / Insert mode
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
}
set -o vi
zle -N zle-line-init
zle -N zle-keymap-select
# Increase the switching time between insert and normal mode in vim
autoload edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment