If you want to verify which code is sent by PuTTY to your terminal when you press a key or a combination of keys, you just have to issue a
Ctrl+V and then press on the desired key.
For example on my box, pressing the Home key will generate the following string on my terminal:
That means that PuTTY sends the escape character ^[ followed by the string [5~.
You can create an
~/.inputrc file in your
$HOME folder, or alternatively an
/etc/inputrc file depending on your system. Then fill this file with the PuTTY codes and the matching Bash actions you want to be triggered by Bash.
Note: Replace every ^[ character by the equivalent \e string
In my example, I'll add a line with my Home key code and the beginning-of-line action (which by default is bound to
Ctrl+A in Bash):
FYI, my inputrc file has the following content:
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line # Home key
"\e[4~": end-of-line # End key
"\e[5~": beginning-of-history # PageUp key
"\e[6~": end-of-history # PageDown key
"\e[3~": delete-char # Delete key
"\e[2~": quoted-insert # Insert key
"\eOD": backward-word # Ctrl + Left Arrow key
"\eOC": forward-word # Ctrl + Right Arrow key
From @Cimbali: More bindable commands (like previous-history: Move `up' through the history list) available on this reference page.