4

I recently discovered terminal's feature, you can set the keys emacs or vi style

I prefer the second. so if you do

set -o vi

You can use k j l h keys to navigate on the command line. And you can switch between 'Normal' and 'Insert' modes like in vim.

However there's no way to visually distinguish one mode from another, even cursor doesn't change. Which makes vi-style pretty much useless. Is there a way to make it truly vim-like?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
iLemming
  • 533
  • 2
  • 6
  • 14
  • 1
    You didn't say which shell you're using. If you're using bash, see [Change cursor shape (or color) to indicate vi mode in bash](http://unix.stackexchange.com/q/22527). If you're using zsh, see [make my zsh prompt show mode in vi mode](http://unix.stackexchange.com/questions/547/make-my-zsh-prompt-show-mode-in-vi-mode). – Gilles 'SO- stop being evil' Feb 22 '14 at 23:08
  • @Gilles, completely missed that. There may be some confusion about what `Terminal` actually does - http://superuser.com/questions/144666/what-is-the-difference-between-shell-console-and-terminal – Graeme Feb 23 '14 at 18:30
  • @Graeme [What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?](http://unix.stackexchange.com/questions/4126/what-is-the-exact-difference-between-a-terminal-a-shell-a-tty-and-a-con) – Gilles 'SO- stop being evil' Feb 23 '14 at 18:32
  • @Gilles, only reason for not linking that one was that there is no mention of `bash` in the top answer... – Graeme Feb 23 '14 at 18:38

2 Answers2

3

As far as I know, this is not possible in Bash. But ZSH supports this. See here.

cbrst
  • 131
  • 2
3

Should be available in bash 4.3 - see the changelog -

j.  New user-settable variable, show-mode-in-prompt, adds a characters to the
    beginning of the prompt indicating the current editing mode.

bash 4.3 is currently at the rc stage, you should be able to get packages for most distros without compiling from source, though not in the main repositories. Eg. Ubuntu (amd64) here and Debian (experimental repo) here.

Graeme
  • 33,607
  • 8
  • 85
  • 110