Joeri Timmermans
Joeri Timmermans
PHP/Symfony Developer with
a passion for food and drinks
Developer @ Intracto

Bash history completion

Monday June 30, 2014 - Permalink - Tags: bash, macosx, linux, autocomplete

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


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".

comments powered by Disqus