Last Updated: February 25, 2016
·
4.21K
· pix-art

Bash history completion

I came across this handy piece of code that allows you to autocomplete commands from your history by using the arrow keys. You can search forward and backward in your history of commands with the current input. It will also ignore cases when searching.

STEP 1: Create .inputrc

vim ~/.inputrc

STEP 2: Paste the following code

"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on

STEP 3: Open a new window

STEP 4: Benefit

Example:

10 commands ago I executed this command "vim ~/.inputrc". Now I would like to repeat it but don't want to look it up in my history or type it all out again. I can now type "vi" and press Arrow Up. And it will auto complete with the last known command that started with "vi" in my case "vim ~/.inputrc".

All my tips have been moved to my blog www.pix-art.be so come check it out!