Friday, March 27, 2015

Linux: search history by up/down arrow keys

In shell, if you want to access the last used commands you can use the up and down arrow keys.
But, if you want to search through the history you have to use the 'Page Up' and 'Page Down' keys. I find it very annoying to use two different set of keys which almost does the same purpose.

How to fix it ? Go to ~/.bashrc and stick these two lines...

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

Now you can go through the history sequentially using the up and down arrow keys and
if you type in a letter and press up/down arrow you will search the history for the commands starting with that letter you typed in. Have fun!

No comments:

Post a Comment