I would like to change some hotkeys in bash to match the dos prompt, because I go back and forth between them. I see that in order to change some of the hotkeys in bash, I need to change the .inputrc file. There are however some really strange characters there that represent keys, but I don't know which key they represent, how can I find that out?

Like these things are pretty odd looking:

"\M-OD": backward-char
"\M-[5~": beginning-of-history
"\M-[5D": backward-word

I am also trying to set the home key to beginning-of-line, but I don't know how to represent the home key

Ted

link|improve this question

53% accept rate
feedback

1 Answer

up vote 1 down vote accepted

Everything you need is explained in the readline(3) manpage. In particular,

  • \C- is the prefix for Ctrl
  • \M- is the prefix for Alt
  • \e is an escape character, sometimes also rendered as ^[
  • in general everything else is literal (excepting some more backslash escapes), so \M-[5D means Alt-[5D on most keyboards.

The easiest way I find of figuring out what special keys translate to is to type them while running cat. For example, on my system, pressing the Up key I get ^[[A which you can type in readline syntax as \e[A. Do the same thing to find out the key codes for Home, End, and anything else you like.

Edit: See also this answer from unix.SE.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.