I'm always little bit confused when bash in vi-mode is switched to insert-mode, because it doesn't give any tip about used mode (command or edit). Is there any way to distinguish mods? May be automatic change of cursor color or something like that?
相关问题
- JQ: Select when attribute value exists in a bash a
- Is it possible to pass command-line arguments to @
- bash print whole line after splitting line with if
- “command not found” errors in expect script execut
- grep using grep results
相关文章
- Check if directory exists on remote machine with s
- Linux - change the hostname in the CLI
- Reverse four length of letters with sed in unix
- Launch interactive SSH bash session from PHP
- BASH: Basic if then and variable assignment
- Bash script that creates a directory structure
- Test if File/Dir exists over SSH/Sudo in Python/Ba
- How can I create a “tmp” directory with Elastic Be
Building on @Isaac Hanson's answer you can set the cursor style to reflect the mode (just like in VIM) by setting these in your
.inputrc
:This will give you a beam cursor in insert mode or a block cursor for normal mode.
Other options (replace the number after
\e[
):Your terminal must support DECSCURSR (like xterm, urxvt, iTerm2). TMUX also supports these (if you set
TERM=xterm-256color
outside tmux).in /etc/inputrc (or ~/.inputrc) add this:
this will prefix your prompt with + while in insert-mode, and : while in command mode in bash 4.3
EDIT: in the latest version of bash 4.4, you will instead get a prompt prefixed with "(ins)" or "(cmd)" by default. but, you can change that:
also, you can use color codes like '\e[1;31m', but surround them with '\1' and '\2' to keep readline happy:
After years of using vi mode in korn shell, I have basically trained myself to just tap
ESC
a few times before I type any commands, andESC
theni
to start typing.The basic premise being that if you just hit
ESC
, you know precisely what mode you are in.