PIX-ART

Joeri Timmermans

IT Consultancy
Kruisstraat 30 bus 002, 3120 Tremelo
+32 477 39 91 34
info@pix-art.be
BE 0679.905.761

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

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

comments powered by Disqus