Supercharge Your Command Line’s History Search With Four Lines Of Code

3
Supercharge Your Command Line’s History Search With Four Lines Of Code

Mac/Linux: Pressing the up and down arrow lets you step through your history in the command line, but sometimes it can take a while to get your way to the command you want. Jude Robinson, posting on Coder Wall, shares four lines of code that make your search much faster.

With four lines, you’ll be able to type the beginning of the command (e.g. “cd”) and press the up arrow to see the most recent command containing the text you typed (e.g “cd ~/Library”). This makes it much easier to find what you’re looking for. To make this happen, create a text file called .inputrc in your home folder and put the following four lines inside:

"e[A": history-search-backward
 "e[B": history-search-forward
 set show-all-if-ambiguous on
 set completion-ignore-case on

Once you do, open up your favourite Terminal Emulator (here are our favourites for OS X and Linux) and give a try.

The single most useful thing in bash [Coder Wall]

Comments

Log in to comment on this story!