Veja o link
You can determine the character sequence emitted by a key by pressing
Ctrl-v
at the command line, then pressing the key you're interested in. On my system for F12, I get^[[24~
. The^[
represents Esc. Different types of terminals or terminal emulators can emit different codes for the same key.At a Bash prompt you can enter a command like this to enable the key macro so you can try it out.
bind '"\e[24~":"foobar"'
Now, when you press F12, you'll get "foobar" on the command line ready for further editing. If you wanted a keystroke to enter a command immediately, you can add a newline:
bind '"\e[24~":"pwd\n"'
A página man do bash contém isso
bind [-m keymap] -x keyseq:shell-command
bind [-m keymap] keyseq:function-name
Se o seu shell não é bash, sugiro examinar a página man do seu shell preferido para obter uma capacidade equivalente.