Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: getting zle vi-modes to show the current mode

For the purpose of the archives (that I didn't manage to search well
enough in the first place), I thought it might be a good idea to show
the solution I eventually came to.  The following will print the
current mode on the line below the prompt.  The only flaw I know of is
that a long line that wraps at the edge of the terminal will overwrite
the mode indicator until either the next line or the next mode change.

If anyone can make any suggestions for improvements, I'd be happy to hear them.

Thanks for the help, all!


bindkey -v

function my-accept-line {
 zle .accept-line
zle -N my-accept-line
bindkey "^M" my-accept-line
bindkey "^J" my-accept-line

setopt prompt_subst;
PS1=$'%{\e7\e[${COLUMNS}G \e[K-- INSERT --\e8\e[B\e[A%}'"$PS1"
PS2=$'%{\e7\e[${COLUMNS}G \e[K-- INSERT --\e8\e[B\e[A%}'"$PS2"
PS3=$'%{\e7\e[${COLUMNS}G \e[K-- INSERT --\e8\e[B\e[A%}'"$PS3"
PS4=$'%{\e7\e[${COLUMNS}G \e[K-- INSERT --\e8\e[B\e[A%}'"$PS4"

function zle-keymap-select {
 if [[ "$KEYMAP" == vicmd ]]; then
   POSTDISPLAY=$'\n'"-- NORMAL --"
   POSTDISPLAY=$'\n'"-- INSERT --"
zle -N zle-keymap-select

Messages sorted by: Reverse Date, Date, Thread, Author