Tip to improve bash history
Jaap A. Haitsma
jaap at haitsma.org
Mon Nov 17 20:51:27 UTC 2003
Already wanted this feature for ages, now finally discovered how you can
get it to work in bash.
Let's say you have the typed following history in bash
info gcc
make
vi main.c
make
vi Makefile
Now you want to issue another "info gcc". You could press the up arrow
four times but if you bind the <up arrow> to "history-search-backward"
instead of "previous-history" you can type the first characters of the
line you want to repeat and then push the <up arrow>. In this case you
would type i <up arrow> and bash already presents you with the "info
gcc" line. "history-search-backward" and "history-search-forward" only
show you the history entries which match with the character you already
typed. If you do not type anything it just works like the normal
history.
To get this behaviour always add the following two lines to your
/etc/inputrc
"\M-[A":history-search-backward
"\M-[B":history-search-forward
Have fun with it
Jaap
More information about the users
mailing list