Binding Individual Keys or Sequences in BASH

Edward J Brash

Bash, upon startup, will look in the file defined by the environment variable INPUTRC. On RH6.0 systems, this appears to be defined to be /etc/inputrc by default, but the bash man page says ~/.inputrc is common, so on your system it may be this way. In any case, the default /etc/inputrc looks like this:

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e0d": backward-word
"\e0c": forward-word
"\e[h": beginning-of-line
"\e[f": end-of-line
"\e[1~": beginning-of-line
"\e[4~": end-of-line 
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

I added the following lines.

"\C-p":"ps aux | grep "
"\C-f":"find . -type f -name "
"\C-g":" | xargs egrep -i "  
"\C-l":"ls -altr"
"\C-w":"who | sort | more"
"\C-v":"history | sort -r -k 1 | more -c"

So, at the command line, I can get the above by executing the appropriate control sequence. For example, by hitting


I get the command:

find . -type f -name "*.txt"  | xargs egrep -i losurs

in a whole lot less keystrokes.