vi-mode.plugin.zsh 700 B

123456789101112131415161718192021222324252627
  1. #
  2. # This plugin is modified to work better with multiline prompts. The problem
  3. # and solutions are described in
  4. # https://github.com/robbyrussell/oh-my-zsh/pull/597
  5. # (basically, zle-line-init is taken out)
  6. #
  7. function zle-keymap-select {
  8. zle reset-prompt
  9. }
  10. zle -N zle-keymap-select
  11. bindkey -v
  12. # if mode indicator wasn't setup by theme, define default
  13. if [[ "$MODE_INDICATOR" == "" ]]; then
  14. MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
  15. fi
  16. function vi_mode_prompt_info() {
  17. echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
  18. }
  19. # define right prompt, if it wasn't defined by a theme
  20. if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then
  21. RPS1='$(vi_mode_prompt_info)'
  22. fi