5

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:

enter image description here

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?

marked as duplicate by jasonwryan, Renan, daisy, Mat, manatwork Nov 1 '12 at 7:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Don't think this is possible - 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:59
  • 1
    This questions was asked over at stackoverflow. – donothingsuccessfully Oct 31 '12 at 18:06
  • 1
    Ah, unfortunately it doesn't look like either of those questions have affirmative answers either. Changing cursor is not quite the same as changing the prompt, so I'd vote as not a duplicate, and there's no way to flag cross-site duplicates, unfortunately. – jw013 Oct 31 '12 at 18:11
  • @jw013 If I bind Escape or my shortcut "kj" to change PS1, will the prompt update before I hit enter? – tlehman Oct 31 '12 at 18:31
  • 1
    If switching to zsh is an option, see this question – Stéphane Chazelas Oct 31 '12 at 19:59

Browse other questions tagged or ask your own question.