Use the terminal in vi-mode
Vi-Commands
Copy, move, and delete with vi-keys.
1echo 'set editing-mode vi' >> ~/.inputrc
2echo 'set keymap vi-insert' >> ~/.inputrc
3exec bash
Try ls <C-n> and ls <C-p>
Use python in vi-mode
1echo 'export PYTHON_BASIC_REPL=true' >> ~/.bashrc
2exec bash
Alias Expansion
1echo '"\C- ": shell-expand-line' >> ~/.inputrc
2exec bash
Now you can expand all aliases with 'Control + Space'.
Try just ls, then 'Control + Space'.
Glob Expansion (*)
1echo '"\C-x": glob-expand-word' >> ~/.inputrc
2exec bash
3ls *<C-x>
Are you sure you want to delete that?
1rm -r *<C-x>`
Clean up the Downloads folder:
1rm Downloads/*pdf<C-x>`
Arbitrary Commands
Make a keyboard shortcut to type anything.
Use \n as a 'newline' character to automatically press <Return>.
1echo 'Control-y: "| lolcat\n"' >> ~/.inputrc
2exec bash
3ls<C-y>
Clear the screen and have a fresh look with C-l.
1Control-l: "\C-u clear -x && ls\n"
2exec bash
3cd /etc/<C-l>
Fix Globs!
If you put the vi-commands in the wrong place in .inputrc, they stop working.
Put them at the start:
1sed '/ vi/d' ~/.inputrc
2sed -i '/ vi/d' ~/.inputrc
3
4sed '1 i set editing-mode vi' .inputrc
5sed -i '1 i set editing-mode vi' ~/.inputrc
6sed -i '2 i set keymap vi-insert' ~/.inputrc
Vi-sibility
The readline prompt becomes confusing if you don't remember if you're in insert or normal mode.
But you can show the current mode in the prompt:
1echo 'set show-mode-in-prompt on' >> ~/.inputrc
2exec bash
Set new symbols for normal and insert mode:
1echo 'set vi-ins-mode-string " "' >> ~/.inputrc
2echo 'set vi-cmd-mode-string " "' >> ~/.inputrc