Command-line History Autocomplete in OS-X

A really nice command-line trick is to enable history autocomplete via up and down arrows. For example, if I am looking for an old ‘grep’ command, I could cycle through all greps in my history simply by typing ‘grep’ UP-ARROW.

All you need to do is add the following lines to the ‘.profile’ file in your home directory.

# make bash autocomplete with up arrow/down arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

Note – You’ll need to start a new terminal session for this to take effect.

Advertisement

About mcoopet

Co-founder of Code 42 Software, Inc. The guy behind the scenes at work and at home
This entry was posted in Mac, OS-X. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s