Thursday, July 2, 2009

PageUp and PageDown history search auto completion on the BASH shell

The Electric Toolbox has an excellent tip on enabling your BASH history page up and page down which is a simple task because Ubuntu already contains the definitions in the /etc/inputrc file, just commented out. Thanks for pointing out some of the power behind Ubuntu.

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.

The above makes the change global in scope and affects all users on the system.

Please visit Electric Toolbox if you want more information on making changes only for your login.

No comments:

Post a Comment