Enabling Autocomplete by reverse searching history in LinuxMar 13th, 2010 | By admin | Category: Linux / Freebsd
Being a FreeBSD user I just got used to a very nice feature that would allow me to autocomplete commands based on my history. So for example if 15 commands ago I had typed ‘cat filenames1 > filename2’ and I wanted to retype that command I could just type ‘cat’ and then press up and it would go through my history and bring up the last command I typed starting with ‘cat’ until I got back to the desired command, only bringing up those in my history starting with ‘cat’ of course.
Unfortunately this isn’t the way it works in linux, in linux pressing up, no matter how much you’ve typed so far will just take you back through the command history. Sure you can press ctrl-r but I couldn’t be bothered to figure that out. Besides there is a much cooler way to go about it.
what you do is to edit /etc/inputrc:
vi gedit /etc/inputrc
somewhere around line 40 is the following:
# alternate mappings for “page up” and “page down” to search the history
Uncomment those lines, close term and open an new one and viola! It works the same but with page up and down instead. Beauty! If you didn’t know about this at all go in there and turn it on right now because man this is a time saver and a half. You’ll thank me later!