I use vi command-line editing (set editing-mode vi in ~/.inputrc) in Bash shells.

However, I find it frustrating, that I cannot see whether vi command-line editing is currently in command or input mode.

Is there someway to display the current mode of vi command-line editing in Bash or tmux?

  • 1
    Try show-mode-in-prompt on ... see related Spurious @ symbol at start of bash prompt in Debian Jessie Commented Aug 2, 2019 at 7:47
  • @steeldriver - thank you. Do you know if I can set this option using shopt? Indeed, I can enable vi command-line editing using shopt.
    – Shuzheng
    Commented Aug 2, 2019 at 8:42
  • TBH I don't know - aside from setting it via one of the inputrc files, the only way I know of is using the shell's bind built-in (bind 'set show-mode-in-prompt on') Commented Aug 2, 2019 at 8:59
  • @steeldriver - also, do you know if all vi key-bindings apply to this vi mode? or where can I lookup the actual set of bindings?
    – Shuzheng
    Commented Aug 2, 2019 at 9:01

2 Answers 2


You can add set show-mode-in-prompt on to the readline configuration (~/.inputrc or /etc/inputrc)

If you want to toggle it directly in the shell you can do so via the bind built-in command:

bind 'set show-mode-in-prompt on'

bind 'set show-mode-in-prompt off'

See the related Spurious @ symbol at start of bash prompt in Debian Jessie


You can set the cursor style to reflect the mode by setting these in your .inputrc:

set editing-mode vi
set show-mode-in-prompt on
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2

# optionally:
# switch to block cursor before executing a command
set keymap vi-insert
RETURN: "\e\n"

This will give you a beam cursor in insert mode or a block cursor for normal mode.

For more see https://stackoverflow.com/a/42107711/52817

  • Thanks. What is a block cursor? Also, do you know if show-mode-in-prompt isn't available for Bash in macOS (can only get it to work on Debian).
    – Shuzheng
    Commented Aug 3, 2019 at 10:08
  • Yes, on mac you need to update bash via homebrew first. block cursor is a rectangle instead of the beam.
    – laktak
    Commented Aug 3, 2019 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .