To support alternative key mappings you can use the GNU readline library's inputrc
init file.
Each user can have their own .inputrc
file in their home directory. Or use global /etc/inputrc
to set it for all users.
To check the current key map, enter verbatim mode (Ctrl-v
) followed by the key to map. This will prevent the shell
from parsing and executing the key and provide the key sequence.
E.g.
Ctrl-v Home
^[[1~
The ^[
sequence is equivalent to the [Esc]
key, so needs to be mapped as e\
.
To test a new map use the bind
command:
bind '"\e[1~": beginning-of-line'
Once this works, you can either add the bind
command to your shell profile or add all the maps to your .inputrc
file.
For Debian / Ubunutu based key mappings, add the following into your personal ~/.inputrc
file:
# for linux console and RH/Debian xterm
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
Then log in again or start a new shell.