Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
up vote 2 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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