bash history & completion tips

This is an oldie… bind the up and down arrow keys to searching `bash` history:

UPDATE:

The post below shows the old method… Here’s an updated version:


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

# make tab cycle through commands instead of listing
bind '"\t":menu-complete'

http://www.macosxhints.com/article.php?story=20031026174236860

Type this into vi ~/.bash_profile, and in place of

<up>

type control + v, then up arrow. In place of

<down>

type control + v then down arrow. (Control V tells vi to put the next character in the doc, rather than just moving up when you press up arrow etc.)


bind '"<up>":history-search-backward'
bind '"<down>":history-search-forward'

Then close all Terminal windows, and quit the app, then open Terminal again and you should have the feature.

also…

PS, don’t forget to add these to your .inputrc while you’re at it:
set show-all-if-ambiguous on
set completion-ignore-case on