May 12, 2014

Linux bash history with Page up / Page down

n linux you can configure the pgup/pgdown keys to navigate through commands you typed that begin with the string you just typed. Type "mysql" and then hit "Page up", and you will see nothing but mysql-related commands.
Unfortunately this has to be configured anew on every machine or server/vm I work on, and I always forget where this is configured (and it takes a while to find it in google), so I thought I should write it down.
------------
In /etc/inputrc, uncomment:
# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
Restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read.
(thanks stackoverflow)
Yep, it's not ".bashrc" but "inputrc".
Not sure why this one is not hidden, but so it is.
You could try ~/.inputrc for a local, user-specific configuration.
Tried this in Ubuntu, and it works.

No comments:

Post a Comment