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

Re: Fwd: In Vi mode, show whether "insert" or "command" state is active

Bart wrote:
> } zle-keymap-select () {
> }     if [ $KEYMAP = vicmd ]; then
> }         echo -en "\e[5 q"
> }     else
> }         echo -en "\e[1 q"
> }     fi
> }     zle reset-prompt
> } }
> } zle -N zle-keymap-select
> You don't even need the reset-prompt in that case because you're echo'ng
> a nonprinting sequence that causes the terminal to change the cursor
> shape.

However, you will need to ensure that the cursor is always reset when a
line is accepted. Most reliable place to do that appears to be POSTEDIT:
  POSTEDIT+=$'\e[2 q'

I find the cursor shape is actually much better than the prompt (or
right prompt) for indicating the mode. Only problem is that it can be
hard to find a narrow bar style cursor in a screenful of text.

I'd also recommend configuring either the zle highlighting of the region
or the cursor to use some colour. If you take the defaults of both zsh
and most terminal emulators, the cursor is a large inverse block and the
region is highlighted in inverse video. This makes it hard to tell where
the cursor is and whether the cursor position is included in the region
or not.


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