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]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


3 responses to “Supercharge Your Command Line’s History Search With Four Lines Of Code”

Leave a Reply