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!
Written by Joeri Timmermans
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#