Bash – Change cursor shape (or color) to indicate vi mode in bash

bashline-editorvi

To clarify: I am not asking how to change the cursor when using vim within a terminal. I want the cursor to change when switching between input and command mode within Bash's vi-mode:

set -o vi <CR> type some text <ESC> (the cursor changes shape/color)
i (cursor change back) etc... 

I found a script that makes changing color of the cursor on mode changes possible in zsh, but I don't want to change shells just for this one feature.

Is there a way to get the cursor to change shape, like in gvim, (or even just color) when switching between command and insert modes on the Bash command line?

Best Answer

add these two lines to ~/.inputrc :

set vi-ins-mode-string \1\e[5 q\2
set vi-cmd-mode-string \1\e[2 q\2
Related Question