Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I understand that the format for key bindings in inputrc file is:

keyname: function-name or macro

For keyname, I saw things like:

"\e[B"
"\e[1~"
"\e[5D"
"\M-l"
"\C-[OD"
"\e\e[D"

What is the meaning of these keynames, and what is the general format for keyname ? Please share a link to docs.

share|improve this question

migrated from superuser.com Nov 7 '11 at 20:53

This question came from our site for computer enthusiasts and power users.

1  
For your docs, I'd recommend looking at the readline(3) manpage or the readline user manual. –  jw013 Nov 11 '11 at 6:10

1 Answer 1

up vote 4 down vote accepted

Keybinding can be done using one of the following forms:

  1. keyname: command_name
  2. "keystroke_sequence": command_name

In first form you can spell out the name for a single key. For example, CONTROL-U would be written as control-u. This is useful for binding commands to single keys.

In the second form, you specify a string that describes a sequence of keys that will be bound to the command. The one you gave as an example is the emacs-tyle backslash escape sequences to represent the special keys

\C - Control
\M - Meta
\e - Escape

You can specify a backslash using another backslash – \\. Similarly ' and " can be escaped too - \' and \"

Update

These characters is what is interpreted by your terminal when you press special keys. You don't want to bind regular alphabets and numerics in your key binding as you might be using them on regular basis and can cause issues when you accidentally hit a combination that has been mapped in your ~/.inputrc or /etc/inputrc file.

[1~ is what is interpreted by your terminal when you press your HOME button. 

To learn more, simply type read on your terminal prompt and press all types of special keys like Function Keys, HOME, END, Arrow Keys etc and see what gets displayed.

Here is a small reference I found that can offer some basic understanding. Good luck! :)

share|improve this answer
    
What does \e[1~, \M-l and \C-[OD mean? The \e, \M, and \C parts are clear. How about the rest? For example: [1~ - Should I press Shift+{+1+Shift+`? –  Misha Moroshko Nov 11 '11 at 21:25
    
I have updated the answer for you. Hope that helps! –  jaypal Nov 12 '11 at 2:00

Your Answer

 
discard

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.