Differences between revisions 3 and 4
Revision 3 as of 2008-11-22 14:08:29
Size: 841
Editor: localhost
Comment: converted to 1.6 markup
Revision 4 as of 2008-11-22 21:53:31
Size: 844
Editor: GreyCat
Comment: first-line
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Just add the following to `/etc/inputrc` or your `~/.inputrc`:
Line 4: Line 5:
Just add the following to `/etc/inputrc` or your `~/.inputrc`
Line 9: Line 9:

I want history-search just like in tcsh. How can I bind it to the up and down keys?

Just add the following to /etc/inputrc or your ~/.inputrc:

"\e[A":history-search-backward
"\e[B":history-search-forward

Then restart bash (either by logging out and back in, or by running exec bash).

Readline (the part of bash that handles terminal input) doesn't understand key names such as "up arrow". Instead, you must manually discern the escape sequence that the key sends on your particular terminal (usually by pressing Ctrl-V and then the key in question), and insert it into the .inputrc as shown above. \e denotes the Escape character in readline. The Ctrl-V trick shows Escape as ^[. You must recognize that the leading ^[ is an Escape character, and make the substitution yourself.

BashFAQ/051 (last edited 2008-11-22 21:53:31 by GreyCat)