2022年4月4日 星期一

ANSI escape code

 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 for readline

       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"

To get a list of which escape sequences correspond to which keyboard-keys, you can use a command such as infocmp -L -1 or infocmp -L -1 xterm

沒有留言: