Понимание управляющих символов в .inputrc

6816
Amelio Vazquez-Reina

Моя учетная запись Linux на удаленной машине имеет следующие предопределенные .inputrc

"\e[1~": beginning-of-line "\e[4~": end-of-line “\e[5~”: history-search-backward “\e[6~”: history-search-forward "\e[3~": delete-char "\e[2~": quoted-insert "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word  set completion-ignore-case on set bell-style visible set expand-tilde on set convert-meta off set input-meta on set output-meta on set show-all-if-ambiguous on set visible-stats on 

Я читаю Баш документации GNU по теме, но я не смог найти раздел, объясняющий, какие последовательности символов \e[1~, \e[5C, \e\e[Dи т.д. означают.

Я думаю, что я где - то читал, что \eозначает, что meta character(я думаю, Altв моей клавиатуре), но не понимаю, что другие управляющие символы [, ~, и 5Dт.д. означают.

Кто-нибудь знает хорошую ссылку на тему?

16

1 ответ на вопрос

17
RedGrittyBrick

These are ANSI control-code escape sequences that are transmitted when various non alphanumeric keys are pressed on a "terminal" keyboard.

\e means the ASCII "ESCAPE" character (octal 033 hex 1B decimal 27). Which is part of a command sequence introduction (CSI).

Escape [ 2 ~ is a character sequence transmitted when you press the key labelled "Insert" on a VT220 (or later) terminal.

Many of these conventions have been adopted in software such as xterm and Linux consoles / shells - often extended in various, sometimes incompatible ways.

The use of these sequences in bash's READLINE function is described in the man pages

 In the second form, "keyseq":function-name or macro, keyseq differs from keyname above in that strings denoting an entire key sequence may be specified by placing the sequence within double quotes. Some GNU Emacs style key escapes can be used, as in the following example, but the symbolic character names are not recognized. "\C-u": universal-argument "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1" 
Отлично!! Это именно то, что я искал. Спасибо @RedGrittyBrick! Amelio Vazquez-Reina 13 лет назад 0
+1. Я искал код `Ctrl` в` inputrc` -> `ENTER` =` Ctrl` + `n`. rendon 10 лет назад 0