Different bash prompt for different vi editing mode?

Thomas picture Thomas · Jun 24, 2009 · Viewed 17.7k times · Source

When using vi mode (set -o vi) with Bash, it would be nice to have a prompt that depends on the mode you are currently in (insert or command). How does one find out this editing mode?

B.t.w, this seems to be possible in ZSH:

Answer

eMPee584 picture eMPee584 · Jun 17, 2013

Fresh bash 4.3 and readline 6.3 have something for you guys.. from the changelog:

4.  New Features in Readline
j.  New user-settable variable, show-mode-in-prompt, adds a characters to the
    beginning of the prompt indicating the current editing mode.

So putting

set show-mode-in-prompt on

into /etc/inputrc or ~/.inputrc (thx stooj) should affect all your readline-enabled programs ;)