History search auto completion on the BASH shell on Ubuntu

A few days ago I posted about enabling the PageUp and PageDown keys for history search auto completion in the BASH shell, looking at what needs to be done to configure it for CentOS 5. Now that I’ve just set up Kubuntu in a VMWare Virtual Machine as my primary Linux desktop, I needed to have the same thing working. I spend a fair amount of time doing stuff from the command line, and being able to search through the history in this way is very important to me.

Fortunately in Kubuntu (which will also mean Ubunutu and all the other variants such as Xubuntu, Edubuntu and Linux Mint) this is easier than for CentOS 5, because it already contains the definitions in the /etc/inputrc file, just commented out.

The file looks like this by default:

...
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
"e[5~": beginning-of-history
"e[6~": end-of-history

# alternate mappings for "page up" and "page down" to search the history
# "e[5~": history-search-backward
# "e[6~": history-search-forward
...

So it’s just a matter of commenting out the original definitions for “e[5~” and “e[6~” and uncommenting the ones for history-search-backward and history-search-forward like so:

...
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
# "e[5~": beginning-of-history
# "e[6~": end-of-history

# alternate mappings for "page up" and "page down" to search the history
"e[5~": history-search-backward
"e[6~": history-search-forward
...

And that’s all there is to it. You need to log out and log in again for the changes to take effect. As in my earlier post, I’m unsure if there is a way to change this on a user by user basis, or if the new setting can be reloaded without having to log out and back in again. If there is I’d be interested to know.

The above makes the change global in scope and affects all users on the system. It’s possible to make the change only for your login by creating/editing a file called .inputrc in your home directory containing just the following:

"e[5~": history-search-backward
"e[6~": history-search-forward