There’s a very simple way to drastically improve searching your command line history in the terminal. I saw it in a tweet from LifeHacker yesterday. Lifehacker is full of tricks to speed up your tech workflow. I thoroughly recommend giving them a follow on twitter and checking out the site.
Enhancing Command Line Search
By adding just four lines to a file, you can search back through your history, filtering by command. For instance, type
$ ls and hitting up will show you all the different directories you’ve listed in the past. Sweet! It worked as described for me in iTerm 2 and I made no mods of my own, so without further a do here’s the link.
While it’s true I made no mods, I came up with this. It’s a simple one line command. Copy and paste it into any terminal window, hit enter, and from now on, each time you open a terminal window, you’ll have the enhanced search functionality. Note: if you already have a
~/.inputrc file, this code snippet will overwrite the contents of your file. In this case it’s best to add the lines manually.
$ echo -e '"e[A": history-search-backwardn"e[B": history-search-forwardnset show-all-if-ambiguous onnset completion-ignore-case on' > ~/.inputrc