Possible Duplicate:
Change cursor shape (or color) to indicate vi mode in bash
I am using vi-mode in a bash shell, and I would like to change the PS1 variable whenever I am in insert mode. When I run bind -v | awk '/keymap/ {print $3}'
, the result is vi-insert
for insert mode and vi
for normal mode.
I would like some visual indicator of which mode I am in, such as a yellow prompt or a dot, something like this:
I would like this visual change to happen as soon as the mode changes, even if no command is run. Is it possible to change the value of PS1 for the current process and update the prompt without hitting enter?
bash
only prints the prompt when you do things like hit enter or clear the screen. And readline key-binding only supports binding a key to a single action - otherwise I'd suggest binding your mode-switch key to also update the prompt. – jw013 Oct 31 '12 at 17:59PS1
is only used to print the prompt - changes to it will only visible the next time it is used. You would need the mapping to cause the prompt to be rewritten or to rewrite it yourself. – jw013 Oct 31 '12 at 18:36