#772985 In Vi mode, show whether "insert" or "command" state is active

Package:
zsh
Source:
zsh
Description:
shell with lots of features
Submitter:
Jason Spiro
Date:
2014-12-12 21:21:05 UTC
Severity:
wishlist
#772985#5
Date:
2014-12-12 18:31:39 UTC
From:
To:
Package: zsh
Version: 4.3.17-1
Severity: wishlist

Zsh includes a Vi emulation feature.  This feature lets you use the Vi
keys at the zsh command prompt.  Zsh's Vi emulation includes a
"command mode" and an "insert mode".

Zsh's Vi emulation does not show the user which mode is active.  This
is frustrating and confusing.  (It's like an electric oven with no
indicator to show whether the oven is on or off.)

The current state-of-the-art Vi implementation is gVim, maintained by
Bram Moolenaar.  gVim provides a few indicators to tell you which mode
you're in.  One of these indicators is the cursor.  gVim uses a
blinking block cursor in command mode, and a blinking bar in insert
mode.

It would be very good if zsh, too, would show the user which mode was
active.  You can do this any way you like.  I would like it if you did
this by setting the cursor style, just as gVim does.

Here is how to set the cursor style (in supported terminals):

Set cursor to blinking bar:  echo -en "\e[5 q"
Set cursor to blinking block:  echo -en "\e[1 q"

The above commands definitely work in recent versions of iTerm2 (for
Mac OS) and xterm.  I haven't tested them in any other terminal
emulators.  Surely some terminal emulators do nothing at all in
response to the above control sequences.  Luckily, since Debian is
open source, their users can submit patches to fix this.

P.S.  Thank you very much for helping to maintain zsh.  It's perhaps
the most featureful shell out there, and I like it.

Kind regards,

#772985#10
Date:
2014-12-12 21:17:45 UTC
From:
To:
Hi Jason,

Jason Spiro wrote:

There are quite some examples out there how to configure/implement
that in your .zshrc. The first hit on DuckDuckGo[1] even has a link to
further implementations[2] which again have links to further
implementations[3][4].

[1] http://paulgoscicki.com/archives/2012/09/vi-mode-indicator-in-zsh-prompt/
[2] https://superuser.com/questions/151803/how-do-i-customize-zshs-vim-mode
[3] http://zshwiki.org/home/examples/zlewidgets
[4] https://pthree.org/2009/03/28/add-vim-editing-mode-to-your-zsh-prompt/

Especially [3] and [4] have very compact examples.

The idea of Zsh packaged for Debian is to preset as less as necessary
and allow the users to configure zsh completely to their tastes.

So this is nothing we would implement in Debian's zsh, but if someone
thinks it would be nice to have a pre-configured prompt with this
feature included in the shipped example prompts, please contact
upstream at zsh-workers@zsh.org -- preferable with an according patch.

Thanks, you're welcome!

		Regards, Axel