rb-readline
rb-readline copied to clipboard
Escape sequences not parsed from .inputrc
rb-readline will read a user's ~/.inputrc
(or /etc/inputrc
), like GNU Readline, but when reading keybindings from those files, rb-readline doesn't understand escape sequences. This means that (1) .inputrc
files are difficult for rb-readline users to make because they must contain literal versions of control and escape characters, and (2) GNU Readline and rb-readline will interpret the same keystrokes from a single .inputrc
file completely differently.
To test this, put basically any binding in your ~/.inputrc
file using the textual notation of Readline and you'll see it work in something like Bash and fail under rb-readline. For instance:
"\C-h": "Why, hello there!"
Here's the relevant portion of the GNU Readline man page detailing the escape sequences that should be available in a .inputrc
:
"KEYSEQ": FUNCTION-NAME or MACRO
KEYSEQ differs from KEYNAME above in that strings denoting an
entire key sequence can be specified, by placing the key
sequence in double quotes. Some GNU Emacs style key escapes
can be used, as in the following example, but the special
character names are not recognized.
"\C-u": universal-argument
"\C-x\C-r": re-read-init-file
"\e[11~": "Function Key 1"
In the above example, `C-u' is again bound to the function
`universal-argument' (just as it was in the first example),
`C-x C-r' is bound to the function `re-read-init-file', and
`<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
Key 1'.
The following GNU Emacs style escape sequences are available when
specifying key sequences:
`\C-'
control prefix
`\M-'
meta prefix
`\e'
an escape character
`\\'
backslash
`\"'
<">, a double quotation mark
`\''
<'>, a single quote or apostrophe
In addition to the GNU Emacs style escape sequences, a second set
of backslash escapes is available:
`\a'
alert (bell)
`\b'
backspace
`\d'
delete
`\f'
form feed
`\n'
newline
`\r'
carriage return
`\t'
horizontal tab
`\v'
vertical tab
`\NNN'
the eight-bit character whose value is the octal value NNN
(one to three digits)
`\xHH'
the eight-bit character whose value is the hexadecimal value
HH (one or two hex digits)
When entering the text of a macro, single or double quotes must be
used to indicate a macro definition. Unquoted text is assumed to
be a function name. In the macro body, the backslash escapes
described above are expanded. Backslash will quote any other
character in the macro text, including `"' and `''. For example,
the following binding will make `C-x \' insert a single `\' into
the line:
"\C-x\\": "\\"