0

As some of you guys know, you could access the vim keybindings in the terminal by modifying a ~/.bashrc or ~/.inputrc file. (Info here)

Hence, your terminal has an insert and normal mode, similar to vim. However, I don't know when I'm typing in insert nor normal mode while using my terminal.

Is there a way you could change the terminal's cursor so you know which mode you're in? (You can already do this in vim.)

Note: I am currently using iterm2 on my mac, and I am using bash, not zsh.

hlin117
  • 20,764
  • 31
  • 72
  • 93
  • You might be able to do something by binding the mode switching keys to switching mode and sending the right escape sequences but I'm not in a position to try it at the moment. – Etan Reisner Dec 17 '14 at 04:06
  • Hmm, unfortunately, if you hit escape more than once to enter normal mode, then your cursor will think that it is in insert mode instead of normal mode. – hlin117 Dec 17 '14 at 04:25
  • I don't think I understood that. – Etan Reisner Dec 17 '14 at 04:26
  • http://stackoverflow.com/questions/1039713/different-bash-prompt-for-different-vi-editing-mode. – FDinoff Dec 17 '14 at 04:47
  • Thank you for the link, @FDinoff. Based on your link, I just upgraded my bash to 4.3, and made my ~/.inputrc file look like this: https://github.com/hlin117/dotfiles/blob/master/.inputrc However, this doesn't fix the problem. Would you know why? – hlin117 Dec 17 '14 at 05:17
  • The user here seems to have the feature working: https://gist.github.com/ethagnawl/86a0284c990196ae31b7. I also commented out line 28 here, but there was no change: https://github.com/hlin117/dotfiles/blob/master/.bashrc – hlin117 Dec 17 '14 at 05:20
  • @hlin117 it doesn't change the cursor but it shows a `+` at the beginning of the line when it is in insert mode and `:` when in normal mode. (Sorry I didn't make this clear earlier). But opening a new shell should make it show up. – FDinoff Dec 17 '14 at 05:20
  • @FDinoff: I tried opening a new terminal, but there's no indication of a + or : symbol anywhere near my prompt. – hlin117 Dec 17 '14 at 05:27
  • @hlin117 I don't know. Something is misconfigured... Make sure you are really running bash 4.3 (`echo $BASH_VERSION`). They inputrc looked fine to me. – FDinoff Dec 17 '14 at 05:30
  • Thank you for your quick follow ups, @FDinoff. It seems that `bash --version` is returning `4.3.30`, but `echo $BASH_VERSION` is returning `3.2.43`. I'm looking into this issue right now. – hlin117 Dec 17 '14 at 05:58
  • Yes, with some quick poking around, the feature is working, @FDinoff. (I followed all of the steps in the first link you posted.) Thank you! – hlin117 Dec 17 '14 at 06:06
  • 2
    Vi key-bindings are not as useful as they seem to be, if only because of the nature of the command-line: a place where you *insert* text. If you seriously need more editing capabilities use a real editor with ``. – romainl Dec 17 '14 at 08:43
  • see http://stackoverflow.com/a/42107711/52817 – laktak Feb 08 '17 at 08:08

0 Answers0