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.

Leave a Reply