When you press Ctrl+L in bash default mode the screen is cleared. But when I run
set -o vi and press Ctrl+L the keystroke is printed (
Is there any way to keep this behavior?
Ctrl+L is also bound in
vi command mode but not in insert mode. There's no default binding for
clear-screen in insert mode. Readline bindings should be specified in
~/.inputrc, like so:
set editing-mode vi $if mode=vi set keymap vi-command # these are for vi-command mode Control-l: clear-screen set keymap vi-insert # these are for vi-insert mode Control-l: clear-screen $endif
This will bind Ctrl+L to clear the screen in both normal and insert mode. Naturally, if you prefer to only use it in one mode, just remove the relevant option.
If you prefer to set this just for
bash use the following equivalents in
set -o vi bind -m vi-command 'Control-l: clear-screen' bind -m vi-insert 'Control-l: clear-screen'
There is an extensive list of readline commands that you can use to customize your bash shell with.