|Linux System Administration|
Configuring hotkeys for the console
There are two types of hotkeys to create in Linux: console hotkeys and X hotkeys. This explains how to configure console hotkeys on a Debian Linux system.
1. Making hotkeys on the Linux console
There are three things you have to do to make a console hotkey:
The first two steps are self-explanatory, so I'll only explain the last two below, which are not so obvious.
2. Key-character sequences
Depending on your terminal type, sequences of key-characters are sent to readline for interpretation. It is these key-character sequences that you want your system to react differently to. But, first you have to find out what they key-character sequence is of the key that you want to configure as a hotkey. To find that out, you use readline's quoted-insert function, which you should find bound to Ctrl-v. It works like this (at the console):
~$ [Ctrl-v] [key(-combination)]
For example, pressing Ctrl-v followed by F10 produces: ^[[21~
3. Configuring readline
More is possible, but the simplest syntax for readline looks like this:
"[key-character sequence]": "[command]"
So, for example, to get Midnight Commander (mc) to start up when F10 is pressed, add the following line to the readline configuration file:
However, in this case hitting F10 would only result in 'mc' showing up on the command line; you'd still have to press Enter to get mc to actually start. To make F10 do mc [ENTER], modify the line as follows:
The Carriage Return is also known as a Control-M, which is what readline's special notation "\C-M" represents.