6c3b9daaf7cd1bf387d46e865f316c6815dc14d2

Author
Tomas Kramar <kramar.tomas@gmail.com>
Committer
Tomas Kramar <kramar.tomas@gmail.com>
Date

Message

Add vi-mode plugin for vi-like editing

Diff

 1diff --git a/plugins/vi-mode.plugin.zsh b/plugins/vi-mode.plugin.zsh
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..c47ab72114562251e4ca75f1395dcaea1abe2002
 4--- /dev/null
 5+++ b/plugins/vi-mode.plugin.zsh
 6@@ -0,0 +1,22 @@
 7+function zle-line-init zle-keymap-select {
 8+  zle reset-prompt
 9+}
10+
11+zle -N zle-line-init
12+zle -N zle-keymap-select
13+
14+bindkey -v
15+
16+# if mode indicator wasn't setup by theme, define default
17+if [[ "$MODE_INDICATOR" == "" ]]; then
18+  MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
19+fi
20+
21+function vi_mode_prompt_info() {
22+  echo "${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
23+}
24+
25+# define right prompt, if it wasn't defined by a theme
26+if [[ "$RPS1" == "" && "$RPROMPT" == "" ]]; then
27+  RPS1='$(vi_mode_prompt_info)'
28+fi