Dear Bart,
thank you for the hint. Indeed, I found an edit-command-line module in zshcontrib.
And yes, it is loaded by oh-my-zsh. So I could fix my theme script.
Unfortunately, I have no idea how to set the MODE variable the way you mentioned.
If anybody wants to tell me, you can find the script at
https://github.com/tannhuber/oh-my-zsh/blob/master/themes/budspencer.zsh-theme
But don't waste your time. Everything is working well, now.
Thank you
Joseph
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> schrieb am 3:50 Donnerstag, 15.Mai 2014:
On May 14, 9:18pm, Sepp Tannhuber wrote:
} Subject: vi-mode: editor function
}
} I have written a theme for the oh-my-zsh prompt from robbyrussel
} because I was sometimes confused about the different vi modes. My
} prompt shows, at a glance, which vi mode is active, similar to the vim
} airline plugin.
[...]
} Unfortunately I could not find something like vi-editor it in the
} zshzle manual. Has anybody an idea what I can use instead? Or what is
} the default vicmd for [v]?
There is no default binding for v in vicmd mode, so you are encountering
something installed for you by oh-my-zsh. Most likely it is the user-
contributed edit-command-line widget (man zshcontrib).
If oh-my-zsh hasn't already pre-empted the zle-line-init, zle-line-finish,
and zle-keymap-select widgets, you might find it more effective to set the
MODE variable with those, rather than trying to override all the individual
widgets that might change mode.
--- budspencer.zsh-theme.orig 2014-05-15 12:47:04.000000000 +0200
+++ budspencer.zsh-theme 2014-05-15 13:16:35.000000000 +0200
@@ -162,76 +162,6 @@
}
# Vi modes
-vi-add-eol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-add-eol
-}
-zle -N vi-add-eol
-bindkey -M vicmd "A" vi-add-eol
-
-vi-add-next() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-add-next
-}
-zle -N vi-add-next
-bindkey -M vicmd "a" vi-add-next
-
-vi-change() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change
-}
-zle -N vi-change
-bindkey -M vicmd "c" vi-change
-
-vi-change-eol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change-eol
-}
-zle -N vi-change-eol
-bindkey -M vicmd "C" vi-change-eol
-
-vi-change-whole-line() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-change-whole-line
-}
-zle -N vi-change-whole-line
-bindkey -M vicmd "S" vi-change-whole-line
-
-vi-insert() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-insert
-}
-zle -N vi-insert
-bindkey -M vicmd "i" vi-insert
-
-vi-insert-bol() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-insert-bol
-}
-zle -N vi-insert-bol
-bindkey -M vicmd "I" vi-insert-bol
-
-vi-open-line-above() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-open-line-above
-}
-zle -N vi-open-line-above
-bindkey -M vicmd "O" vi-open-line-above
-
-vi-open-line-below() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-open-line-below
-}
-zle -N vi-open-line-below
-bindkey -M vicmd "o" vi-open-line-below
-
-vi-substitute() {
- ZSH_VI_MODE="INSERT"
- builtin zle .vi-substitute
-}
-zle -N vi-substitute
-bindkey -M vicmd "s" vi-substitute
-
vi-cmd-mode() {
ZSH_VI_MODE="NORMAL"
builtin zle .vi-cmd-mode
@@ -247,7 +177,6 @@
bindkey -M vicmd "R" vi-replace
vi-edit-command-line() {
- ZSH_VI_MODE="INSERT"
vim_mode=$vim_ins_mode
dir_mode=$dir_ins_mode
fgcolor=136
@@ -264,27 +193,25 @@
vim_cmd_mode="%{%K{33}%}%{%F{0}%}"
vim_rpl_mode="%{%K{160}%}%{%F{0}%}"
vim_mode=$vim_ins_mode
-fgcolor=136
-ZSH_VI_MODE="INSERT"
function zle-keymap-select {
-if [ "$ZSH_VI_MODE" = "INSERT" ]
+if [ "$ZSH_VI_MODE" = "NORMAL" ]
+then
+ vim_mode=$vim_cmd_mode
+ dir_mode=$dir_cmd_mode
+ fgcolor=33
+elif [[ "$ZLE_STATE" = *insert* ]]
then
fgcolor=136
vim_mode=$vim_ins_mode
dir_mode=$dir_ins_mode
-fi
-if [ "$ZSH_VI_MODE" = "REPLACE" ]
+ ZSH_VI_MODE="INSERT"
+elif [[ "$ZLE_STATE" = *overwrite* ]]
then
vim_mode=$vim_rpl_mode
dir_mode=$dir_rpl_mode
fgcolor=160
-fi
-if [ "$ZSH_VI_MODE" = "NORMAL" ]
-then
- vim_mode=$vim_cmd_mode
- dir_mode=$dir_cmd_mode
- fgcolor=33
+ ZSH_VI_MODE="REPLACE"
fi
zle reset-prompt
}