Skip to content

Instantly share code, notes, and snippets.

@nackjicholson
Last active October 13, 2020 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nackjicholson/98d756fb5b39288a296463af1e5aa6ed to your computer and use it in GitHub Desktop.
Save nackjicholson/98d756fb5b39288a296463af1e5aa6ed to your computer and use it in GitHub Desktop.
My old vi keybindings ZSH Prompt config
bindkey -v
bindkey "^R" history-incremental-search-backward
# zle vi mode indication
# http://pawelgoscicki.com/archives/2012/09/vi-mode-indicator-in-zsh-prompt/
setopt PROMPT_SUBST
vim_ins_mode="-- INSERT --"
vim_cmd_mode=""
vim_mode=$vim_ins_mode
function zle-keymap-select {
vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}"
zle reset-prompt
}
zle -N zle-keymap-select
function zle-line-finish {
vim_mode=$vim_ins_mode
}
zle -N zle-line-finish
# Fix a bug when you C-c in CMD mode and you'd be prompted with CMD mode indicator, while in fact you would be in INS mode
# Fixed by catching SIGINT (C-c), set vim_mode to INS and then repropagate the SIGINT, so if anything else depends on it, we will not break it
function TRAPINT() {
vim_mode=$vim_ins_mode
return $(( 128 + $1 ))
}
PROMPT='%~ %# '
RPROMPT='${vim_mode}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment