Saturday, December 30, 2017

Navigate through bash history with page up/down key

Linux bash history with Page up / Page down

In 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.

And I tried it in kde-neon and it works.

Credit goes to Andreas Hennings aka "donquixote". Visit his page about this here

No comments:

Second monitor no display after latest update - KDE-neon

 After latest update as of Oct 3, 2023, my second monitor was undetected with latest kernel (6.2.0-33-generic). If I boot with previous kern...