vi-mode.plugin.zsh 526 B

12345678910111213141516171819202122
  1. function zle-line-init zle-keymap-select {
  2. zle reset-prompt
  3. }
  4. zle -N zle-line-init
  5. zle -N zle-keymap-select
  6. bindkey -v
  7. # if mode indicator wasn't setup by theme, define default
  8. if [[ "$MODE_INDICATOR" == "" ]]; then
  9. MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
  10. fi
  11. function vi_mode_prompt_info() {
  12. echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
  13. }
  14. # define right prompt, if it wasn't defined by a theme
  15. if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then
  16. RPS1='$(vi_mode_prompt_info)'
  17. fi