在哪里可以找到用于在 bash 中重新映射快捷键的终端键代码列表?

在哪里可以找到用于在 bash 中重新映射快捷键的终端键代码列表?

例如:

"\e[1;5C"
"\e[Z"
"\e-1\C-i"

我只知道一些零碎的东西,比如\e代表 escape 和C-for Ctrl,但是这些数字 ( 1) 和字母 ( Z) 是什么?;[和符号代表什么-

是否只有反复试验,或者是否有 bash 键代码的完整列表及其语法解释?

答案1

这些是当您按给定键时终端发送的字符序列。与 bash 或 readline 本身无关,但如果您想配置readline在按下给定按键时执行某些操作,您将需要知道给定按键或按键组合发送的字符序列。

当您按下该A键时,通常终端会发送a(0x61)字符。如果按<Ctrl-I><Tab>,则通常发送^I字符也称为TAB\t(0x9)。大多数功能键和导航键通常发送以^[(control-[) 开头的字符序列,也称为ESC\e(0x1b,八进制 033),但具体序列因终端而异。

找出按键或按键组合向终端发送的内容的最佳方法是运行并在键盘上sed -n l键入它。Enter然后你会看到类似的内容:

$ sed -n l
^[[1;5A
\033[1;5A$

第一行是由echo终端设备完成的本地终端引起的(它可能不可靠,因为终端设备设置会影响它)。

第二行由 输出sed。不包括在内$,它只是向您显示该行的末尾在哪里。

上面这意味着Ctrl-Up(我按下的)发送 6 个字符ESC, [, 1, ;,5A(0x1b 0x5b 0x31 0x3b 0x35 0x41)

数据库terminfo记录了多个终端的多个公共密钥的多个序列(基于$TERM值)。

例如:

TERM=rxvt tput kdch1 | sed -n l

会告诉您rxvt按键时发送的转义序列是什么Delete

您可以使用当前终端查找与给定序列相对应的键infocmp(此处假设为ncursesinfocmp):

$ infocmp -L1 | grep -F '=\E[Z'
    back_tab=\E[Z,
    key_btab=\E[Z,

像这样的组合键Ctrl-Up在数据库中没有相应的条目,因此要了解它们发送的内容,请阅读相应终端的源代码或文档,或者使用上述方法terminfo进行尝试。sed -n l

答案2

它是通过 GNUreadline库提供的。你应该调查一下man 3 readline找出它的描述。

看起来您还需要有关转义码等\[A含义的信息。您可以在维基百科中找到此信息ANSI 转义码文章。

答案3

我发现检查按键或按键组合生成的转义序列的最简单方法是在终端中按Ctrl+ ,然后按您想了解的按键/组合。v

您将得到一个类似的序列^[Oa,并且您必须将 翻译^[\e\033\x1b或您的按键绑定系统期望的转义字符的任何其他表示形式。

它最初是一个名为quoted-insertand 的 Emacs 函数,由于 Bash 和 Zsh 的默认按键绑定模仿 Emacs,所以他们也复制了它。

Bash 通过 GNU Readline 输入库获取它,Python 的import rlcompleter增强等其他东西也使用该库。

这是来自的描述阅读在线手册:

quoted-insertC-q或者C-v

将键入的下一个字符逐字添加到该行。例如,这就是插入键序列的方法C-q

这应该适用于任何事物基于 GNU Readline。

至于 Zsh,它使用自己的替代方案 ZLE,它只C-q在 Vi 模式下尊重原始的 Emacs 绑定,讽刺的是,但C-v仍然可以在默认的类似 Emacs 的输入模式下工作。 (quoted-insertzshzle或手册页中搜索zshall,第二对结果应列出默认按键绑定。)

对于助记符,我建议将Ctrl+v视为请求它v埃尔巴蒂姆。

答案4

Ctrl+V仅适用于某些字符(不显示Tab, Caps, 音量键, Print Screen, Home, End, Pause, Mute) Cv 也不允许反向翻译或换句话说,查看现有的绑定以及它们代表的键。

它确实适用于大多数关键角色,但最好的选择是使用

dumpkey -1 >> mapreference

获取键码的完整表格 - 您的特定键盘为每次按键发送的信号。这些键码与您的地图文件(位于 Arch:/usr/share/kbd/keymap/*/**文件夹中)相匹配,但dumpkeys更容易,因为所有映射都存储在一个位置。

接下来,您将需要转换表,具体取决于它们所键入的格式。

ASCII 转换表

八进制

  000 NUL   020 DLE   040     060 0   100 @   120 P   140 `   160 p 
  001 SOH   021 DC1   041 !   061 1   101 A   121 Q   141 a   161 q 
  002 STX   022 DC2   042 "   062 2   102 B   122 R   142 b   162 r 
  003 ETX   023 DC3   043 #   063 3   103 C   123 S   143 c   163 s 
  004 EOT   024 DC4   044 $   064 4   104 D   124 T   144 d   164 t 
  005 ENQ   025 NAK   045 %   065 5   105 E   125 U   145 e   165 u 
  006 ACK   026 SYN   046 &   066 6   106 F   126 V   146 f   166 v 
  007 BEL   027 ETB   047 '   067 7   107 G   127 W   147 g   167 w 
  010 BS    030 CAN   050 (   070 8   110 H   130 X   150 h   170 x 
  011 HT    031 EM    051 )   071 9   111 I   131 Y   151 i   171 y 
  012 LF    032 SUB   052 *   072 :   112 J   132 Z   152 j   172 z 
  013 VT    033 ESC   053 +   073 ;   113 K   133 [   153 k   173 { 
  014 FF    034 FS    054 ,   074 <   114 L   134 \   154 l   174 | 
  015 CR    035 GS    055 -   075 =   115 M   135 ]   155 m   175 } 
  016 SO    036 RS    056 .   076 >   116 N   136 ^   156 n   176 ~ 
  017 SI    037 US    057 /   077 ?   117 O   137 _   157 o   177 DEL 

二进制

   0000000 NUL    0010000 DLE    0100000      0110000 0    1000000 @    1010000 P    1100000 `    1110000 p
   0000001 SOH    0010001 DC1    0100001 !    0110001 1    1000001 A    1010001 Q    1100001 a    1110001 q
   0000010 STX    0010010 DC2    0100010 "    0110010 2    1000010 B    1010010 R    1100010 b    1110010 r
   0000011 ETX    0010011 DC3    0100011 #    0110011 3    1000011 C    1010011 S    1100011 c    1110011 s
   0000100 EOT    0010100 DC4    0100100 $    0110100 4    1000100 D    1010100 T    1100100 d    1110100 t
   0000101 ENQ    0010101 NAK    0100101 %    0110101 5    1000101 E    1010101 U    1100101 e    1110101 u
   0000110 ACK    0010110 SYN    0100110 &    0110110 6    1000110 F    1010110 V    1100110 f    1110110 v
   0000111 BEL    0010111 ETB    0100111 '    0110111 7    1000111 G    1010111 W    1100111 g    1110111 w
   0001000 BS     0011000 CAN    0101000 (    0111000 8    1001000 H    1011000 X    1101000 h    1111000 x
   0001001 HT     0011001 EM     0101001 )    0111001 9    1001001 I    1011001 Y    1101001 i    1111001 y
   0001010 LF     0011010 SUB    0101010 *    0111010 :    1001010 J    1011010 Z    1101010 j    1111010 z
   0001011 VT     0011011 ESC    0101011 +    0111011 ;    1001011 K    1011011 [    1101011 k    1111011 {
   0001100 FF     0011100 FS     0101100 ,    0111100 <    1001100 L    1011100 \    1101100 l    1111100 |
   0001101 CR     0011101 GS     0101101 -    0111101 =    1001101 M    1011101 ]    1101101 m    1111101 }
   0001110 SO     0011110 RS     0101110 .    0111110 >    1001110 N    1011110 ^    1101110 n    1111110 ~
   0001111 SI     0011111 US     0101111 /    0111111 ?    1001111 O    1011111 _    1101111 o    1111111 DEL

UTF-8

Unicode 
Code Point         Character           UTF-8(hex)         Name

U+0000                                  00               <control>
U+0001                                  01               <control>
U+0002                                  02               <control>
U+0003                                  03               <control>
U+0004                                  04               <control>
U+0005                                  05               <control>
U+0006                                  06               <control>
U+0007                                  07               <control>
U+0008                                  08               <control>
U+0009                                  09               <control>
U+000A                                  0a               <control>
U+000B                                  0b               <control>
U+000C                                  0c               <control>
U+000D                                  0d               <control>
U+000E                                  0e               <control>
U+000F                                  0f               <control>
U+0010                                  10               <control>
U+0011                                  11               <control>
U+0012                                  12               <control>
U+0013                                  13               <control>
U+0014                                  14               <control>
U+0015                                  15               <control>
U+0016                                  16               <control>
U+0017                                  17               <control>
U+0018                                  18               <control>
U+0019                                  19               <control>
U+001A                                  1a               <control>
U+001B                                  1b               <control>
U+001C                                  1c               <control>
U+001D                                  1d               <control>
U+001E                                  1e               <control>
U+001F                                  1f               <control>
U+0020                                  20               SPACE
U+0021                  !               21               EXCLAMATION MARK
U+0022                  "               22               QUOTATION MARK
U+0023                  #               23               NUMBER SIGN
U+0024                  $               24               DOLLAR SIGN
U+0025                  %               25               PERCENT SIGN
U+0026                  &               26               AMPERSAND
U+0027                  '               27               APOSTROPHE
U+0028                  (               28               LEFT PARENTHESIS
U+0029                  )               29               RIGHT PARENTHESIS
U+002A                  *               2a               ASTERISK
U+002B                  +               2b               PLUS SIGN
U+002C                  ,               2c               COMMA
U+002D                  -               2d               HYPHEN-MINUS
U+002E                  .               2e               FULL STOP
U+002F                  /               2f               SOLIDUS
U+0030                  0               30               DIGIT ZERO
U+0031                  1               31               DIGIT ONE
U+0032                  2               32               DIGIT TWO
U+0033                  3               33               DIGIT THREE
U+0034                  4               34               DIGIT FOUR
U+0035                  5               35               DIGIT FIVE
U+0036                  6               36               DIGIT SIX
U+0037                  7               37               DIGIT SEVEN
U+0038                  8               38               DIGIT EIGHT
U+0039                  9               39               DIGIT NINE
U+003A                  :               3a               COLON
U+003B                  ;               3b               SEMICOLON
U+003C                  <               3c               LESS-THAN SIGN
U+003D                  =               3d               EQUALS SIGN
U+003E                  >               3e               GREATER-THAN SIGN
U+003F                  ?               3f               QUESTION MARK
U+0040                  @               40               COMMERCIAL AT
U+0041                  A               41               LATIN CAPITAL LETTER A
U+0042                  B               42               LATIN CAPITAL LETTER B
U+0043                  C               43               LATIN CAPITAL LETTER C
U+0044                  D               44               LATIN CAPITAL LETTER D
U+0045                  E               45               LATIN CAPITAL LETTER E
U+0046                  F               46               LATIN CAPITAL LETTER F
U+0047                  G               47               LATIN CAPITAL LETTER G
U+0048                  H               48               LATIN CAPITAL LETTER H
U+0049                  I               49               LATIN CAPITAL LETTER I
U+004A                  J               4a               LATIN CAPITAL LETTER J
U+004B                  K               4b               LATIN CAPITAL LETTER K
U+004C                  L               4c               LATIN CAPITAL LETTER L
U+004D                  M               4d               LATIN CAPITAL LETTER M
U+004E                  N               4e               LATIN CAPITAL LETTER N
U+004F                  O               4f               LATIN CAPITAL LETTER O
U+0050                  P               50               LATIN CAPITAL LETTER P
U+0051                  Q               51               LATIN CAPITAL LETTER Q
U+0052                  R               52               LATIN CAPITAL LETTER R
U+0053                  S               53               LATIN CAPITAL LETTER S
U+0054                  T               54               LATIN CAPITAL LETTER T
U+0055                  U               55               LATIN CAPITAL LETTER U
U+0056                  V               56               LATIN CAPITAL LETTER V
U+0057                  W               57               LATIN CAPITAL LETTER W
U+0058                  X               58               LATIN CAPITAL LETTER X
U+0059                  Y               59               LATIN CAPITAL LETTER Y
U+005A                  Z               5a               LATIN CAPITAL LETTER Z
U+005B                  [               5b               LEFT SQUARE BRACKET
U+005C                  \               5c               REVERSE SOLIDUS
U+005D                  ]               5d               RIGHT SQUARE BRACKET
U+005E                  ^               5e               CIRCUMFLEX ACCENT
U+005F                  _               5f               LOW LINE
U+0060                  `               60               GRAVE ACCENT
U+0061                  a               61               LATIN SMALL LETTER A
U+0062                  b               62               LATIN SMALL LETTER B
U+0063                  c               63               LATIN SMALL LETTER C
U+0064                  d               64               LATIN SMALL LETTER D
U+0065                  e               65               LATIN SMALL LETTER E
U+0066                  f               66               LATIN SMALL LETTER F
U+0067                  g               67               LATIN SMALL LETTER G
U+0068                  h               68               LATIN SMALL LETTER H
U+0069                  i               69               LATIN SMALL LETTER I
U+006A                  j               6a               LATIN SMALL LETTER J
U+006B                  k               6b               LATIN SMALL LETTER K
U+006C                  l               6c               LATIN SMALL LETTER L
U+006D                  m               6d               LATIN SMALL LETTER M
U+006E                  n               6e               LATIN SMALL LETTER N
U+006F                  o               6f               LATIN SMALL LETTER O
U+0070                  p               70               LATIN SMALL LETTER P
U+0071                  q               71               LATIN SMALL LETTER Q
U+0072                  r               72               LATIN SMALL LETTER R
U+0073                  s               73               LATIN SMALL LETTER S
U+0074                  t               74               LATIN SMALL LETTER T
U+0075                  u               75               LATIN SMALL LETTER U
U+0076                  v               76               LATIN SMALL LETTER V
U+0077                  w               77               LATIN SMALL LETTER W
U+0078                  x               78               LATIN SMALL LETTER X
U+0079                  y               79               LATIN SMALL LETTER Y
U+007A                  z               7a               LATIN SMALL LETTER Z
U+007B                  {               7b               LEFT CURLY BRACKET
U+007C                  |               7c               VERTICAL LINE
U+007D                  }               7d               RIGHT CURLY BRACKET
U+007E                  ~               7e               TILDE
U+007F                                  7f               <control>
U+0080                                  c2 80            <control>
U+0081                                  c2 81            <control>
U+0082                                  c2 82            <control>
U+0083                                  c2 83            <control>
U+0084                                  c2 84            <control>
U+0085                                  c2 85            <control>
U+0086                                  c2 86            <control>
U+0087                                  c2 87            <control>
U+0088                                  c2 88            <control>
U+0089                                  c2 89            <control>
U+008A                                  c2 8a            <control>
U+008B                                  c2 8b            <control>
U+008C                                  c2 8c            <control>
U+008D                                  c2 8d            <control>
U+008E                                  c2 8e            <control>
U+008F                                  c2 8f            <control>
U+0090                                  c2 90            <control>
U+0091                                  c2 91            <control>
U+0092                                  c2 92            <control>
U+0093                                  c2 93            <control>
U+0094                                  c2 94            <control>
U+0095                                  c2 95            <control>
U+0096                                  c2 96            <control>
U+0097                                  c2 97            <control>
U+0098                                  c2 98            <control>
U+0099                                  c2 99            <control>
U+009A                                  c2 9a            <control>
U+009B                                  c2 9b            <control>
U+009C                                  c2 9c            <control>
U+009D                                  c2 9d            <control>
U+009E                                  c2 9e            <control>
U+009F                                  c2 9f            <control>
U+00A0                                  c2 a0            NO-BREAK SPACE
U+00A1                  ¡               c2 a1            INVERTED EXCLAMATION MARK
U+00A2                  ¢               c2 a2            CENT SIGN
U+00A3                  £               c2 a3            POUND SIGN
U+00A4                  ¤               c2 a4            CURRENCY SIGN
U+00A5                  ¥               c2 a5            YEN SIGN
U+00A6                  ¦               c2 a6            BROKEN BAR
U+00A7                  §               c2 a7            SECTION SIGN
U+00A8                  ¨               c2 a8            DIAERESIS
U+00A9                  ©               c2 a9            COPYRIGHT SIGN
U+00AA                  ª               c2 aa            FEMININE ORDINAL INDICATOR
U+00AB                  «               c2 ab            LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
U+00AC                  ¬               c2 ac            NOT SIGN
U+00AD                  ­                c2 ad            SOFT HYPHEN
U+00AE                  ®               c2 ae            REGISTERED SIGN
U+00AF                  ¯               c2 af            MACRON
U+00B0                  °               c2 b0            DEGREE SIGN
U+00B1                  ±               c2 b1            PLUS-MINUS SIGN
U+00B2                  ²               c2 b2            SUPERSCRIPT TWO
U+00B3                  ³               c2 b3            SUPERSCRIPT THREE
U+00B4                  ´               c2 b4            ACUTE ACCENT
U+00B5                  µ               c2 b5            MICRO SIGN
U+00B6                  ¶               c2 b6            PILCROW SIGN
U+00B7                  ·               c2 b7            MIDDLE DOT
U+00B8                  ¸               c2 b8            CEDILLA
U+00B9                  ¹               c2 b9            SUPERSCRIPT ONE
U+00BA                  º               c2 ba            MASCULINE ORDINAL INDICATOR
U+00BB                  »               c2 bb            RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
U+00BC                  ¼               c2 bc            VULGAR FRACTION ONE QUARTER
U+00BD                  ½               c2 bd            VULGAR FRACTION ONE HALF
U+00BE                  ¾               c2 be            VULGAR FRACTION THREE QUARTERS
U+00BF                  ¿               c2 bf            INVERTED QUESTION MARK
U+00C0                  À               c3 80            LATIN CAPITAL LETTER A WITH GRAVE
U+00C1                  Á               c3 81            LATIN CAPITAL LETTER A WITH ACUTE
U+00C2                  Â               c3 82            LATIN CAPITAL LETTER A WITH CIRCUMFLEX
U+00C3                  Ã               c3 83            LATIN CAPITAL LETTER A WITH TILDE
U+00C4                  Ä               c3 84            LATIN CAPITAL LETTER A WITH DIAERESIS
U+00C5                  Å               c3 85            LATIN CAPITAL LETTER A WITH RING ABOVE
U+00C6                  Æ               c3 86            LATIN CAPITAL LETTER AE
U+00C7                  Ç               c3 87            LATIN CAPITAL LETTER C WITH CEDILLA
U+00C8                  È               c3 88            LATIN CAPITAL LETTER E WITH GRAVE
U+00C9                  É               c3 89            LATIN CAPITAL LETTER E WITH ACUTE
U+00CA                  Ê               c3 8a            LATIN CAPITAL LETTER E WITH CIRCUMFLEX
U+00CB                  Ë               c3 8b            LATIN CAPITAL LETTER E WITH DIAERESIS
U+00CC                  Ì               c3 8c            LATIN CAPITAL LETTER I WITH GRAVE
U+00CD                  Í               c3 8d            LATIN CAPITAL LETTER I WITH ACUTE
U+00CE                  Î               c3 8e            LATIN CAPITAL LETTER I WITH CIRCUMFLEX
U+00CF                  Ï               c3 8f            LATIN CAPITAL LETTER I WITH DIAERESIS
U+00D0                  Ð               c3 90            LATIN CAPITAL LETTER ETH
U+00D1                  Ñ               c3 91            LATIN CAPITAL LETTER N WITH TILDE
U+00D2                  Ò               c3 92            LATIN CAPITAL LETTER O WITH GRAVE
U+00D3                  Ó               c3 93            LATIN CAPITAL LETTER O WITH ACUTE
U+00D4                  Ô               c3 94            LATIN CAPITAL LETTER O WITH CIRCUMFLEX
U+00D5                  Õ               c3 95            LATIN CAPITAL LETTER O WITH TILDE
U+00D6                  Ö               c3 96            LATIN CAPITAL LETTER O WITH DIAERESIS
U+00D7                  ×               c3 97            MULTIPLICATION SIGN
U+00D8                  Ø               c3 98            LATIN CAPITAL LETTER O WITH STROKE
U+00D9                  Ù               c3 99            LATIN CAPITAL LETTER U WITH GRAVE
U+00DA                  Ú               c3 9a            LATIN CAPITAL LETTER U WITH ACUTE
U+00DB                  Û               c3 9b            LATIN CAPITAL LETTER U WITH CIRCUMFLEX
U+00DC                  Ü               c3 9c            LATIN CAPITAL LETTER U WITH DIAERESIS
U+00DD                  Ý               c3 9d            LATIN CAPITAL LETTER Y WITH ACUTE
U+00DE                  Þ               c3 9e            LATIN CAPITAL LETTER THORN
U+00DF                  ß               c3 9f            LATIN SMALL LETTER SHARP S
U+00E0                  à               c3 a0            LATIN SMALL LETTER A WITH GRAVE
U+00E1                  á               c3 a1            LATIN SMALL LETTER A WITH ACUTE
U+00E2                  â               c3 a2            LATIN SMALL LETTER A WITH CIRCUMFLEX
U+00E3                  ã               c3 a3            LATIN SMALL LETTER A WITH TILDE
U+00E4                  ä               c3 a4            LATIN SMALL LETTER A WITH DIAERESIS
U+00E5                  å               c3 a5            LATIN SMALL LETTER A WITH RING ABOVE
U+00E6                  æ               c3 a6            LATIN SMALL LETTER AE
U+00E7                  ç               c3 a7            LATIN SMALL LETTER C WITH CEDILLA
U+00E8                  è               c3 a8            LATIN SMALL LETTER E WITH GRAVE
U+00E9                  é               c3 a9            LATIN SMALL LETTER E WITH ACUTE
U+00EA                  ê               c3 aa            LATIN SMALL LETTER E WITH CIRCUMFLEX
U+00EB                  ë               c3 ab            LATIN SMALL LETTER E WITH DIAERESIS
U+00EC                  ì               c3 ac            LATIN SMALL LETTER I WITH GRAVE
U+00ED                  í               c3 ad            LATIN SMALL LETTER I WITH ACUTE
U+00EE                  î               c3 ae            LATIN SMALL LETTER I WITH CIRCUMFLEX
U+00EF                  ï               c3 af            LATIN SMALL LETTER I WITH DIAERESIS
U+00F0                  ð               c3 b0            LATIN SMALL LETTER ETH
U+00F1                  ñ               c3 b1            LATIN SMALL LETTER N WITH TILDE
U+00F2                  ò               c3 b2            LATIN SMALL LETTER O WITH GRAVE
U+00F3                  ó               c3 b3            LATIN SMALL LETTER O WITH ACUTE
U+00F4                  ô               c3 b4            LATIN SMALL LETTER O WITH CIRCUMFLEX
U+00F5                  õ               c3 b5            LATIN SMALL LETTER O WITH TILDE
U+00F6                  ö               c3 b6            LATIN SMALL LETTER O WITH DIAERESIS
U+00F7                  ÷               c3 b7            DIVISION SIGN
U+00F8                  ø               c3 b8            LATIN SMALL LETTER O WITH STROKE
U+00F9                  ù               c3 b9            LATIN SMALL LETTER U WITH GRAVE
U+00FA                  ú               c3 ba            LATIN SMALL LETTER U WITH ACUTE
U+00FB                  û               c3 bb            LATIN SMALL LETTER U WITH CIRCUMFLEX
U+00FC                  ü               c3 bc            LATIN SMALL LETTER U WITH DIAERESIS
U+00FD                  ý               c3 bd            LATIN SMALL LETTER Y WITH ACUTE
U+00FE                  þ               c3 be            LATIN SMALL LETTER THORN
U+00FF                  ÿ               c3 bf            LATIN SMALL LETTER Y WITH DIAERESIS

十进制/十六进制

  Dec Hex    Dec Hex    Dec Hex  Dec Hex  Dec Hex  Dec Hex   Dec Hex   Dec Hex  
  0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60 `  112 70 p
  1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q
  2 02 STX  18 12 DC2  34 22 "  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r
  3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s
  4 04 EOT  20 14 DC4  36 24 $  52 34 4  68 44 D  84 54 T  100 64 d  116 74 t
  5 05 ENQ  21 15 NAK  37 25 %  53 35 5  69 45 E  85 55 U  101 65 e  117 75 u
  6 06 ACK  22 16 SYN  38 26 &  54 36 6  70 46 F  86 56 V  102 66 f  118 76 v
  7 07 BEL  23 17 ETB  39 27 '  55 37 7  71 47 G  87 57 W  103 67 g  119 77 w
  8 08 BS   24 18 CAN  40 28 (  56 38 8  72 48 H  88 58 X  104 68 h  120 78 x
  9 09 HT   25 19 EM   41 29 )  57 39 9  73 49 I  89 59 Y  105 69 i  121 79 y
 10 0A LF   26 1A SUB  42 2A *  58 3A :  74 4A J  90 5A Z  106 6A j  122 7A z
 11 0B VT   27 1B ESC  43 2B +  59 3B ;  75 4B K  91 5B [  107 6B k  123 7B {
 12 0C FF   28 1C FS   44 2C ,  60 3C <  76 4C L  92 5C \  108 6C l  124 7C |
 13 0D CR   29 1D GS   45 2D -  61 3D =  77 4D M  93 5D ]  109 6D m  125 7D }
 14 0E SO   30 1E RS   46 2E .  62 3E >  78 4E N  94 5E ^  110 6E n  126 7E ~
 15 0F SI   31 1F US   47 2F /  63 3F ?  79 4F O  95 5F _  111 6F o  127 7F DEL

请注意,每个表中的前 32 个字符是保留控制字符。控制字符不是可打印字符。它们用于向 PC 发送命令。

现在,如果您想要一些有趣但又有用的东西,这是我正在开发的转义序列注入脚本。它使用fzfandripgrepfd-findrust的书写find),但基于您的术语。 In 将您的术语功能打印到窗口,然后让您递归地搜索术语信息手册页以查找光标下的命令(它按名称 -> 转义序列的顺序)。

选择并点击Enter,它会将其打印到您的命令行中的引号之间和之后,echo -e " "但不会执行(只是这样您可以在我做一些愚蠢的事情之前查看)。

#!/bin/bash !
fzfcmp () {
    local term
    local FZF_DEFAULT_COMMAND
    FZF_DEFAULT_COMMAND="infocmp $TERM -1"
    term="$(
    infocmp "${_termchoice:-"$TERM"}" -1 | tr '=' '\n' | \
       tr '\t' '' | \
      sed 's/,$//' | fzf \
      --preview='man terminfo | rg -C10 -e {q}' \
        --preview-window='right:80:wrap' --phony \
        --bind="f9:reload:changeterm"
    unset _termchoice
    )"


 if test -n "$(rg -e 'echo' <<<"$READLINE_LINE")"; then
    READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT} $(awk -F= '{print $1}' <<<"${term:-''}" \
    | sed 's/,$//') ${READLINE_LINE:$READLINE_POINT}";
    else
    READLINE_LINE="$(echo 'echo -e' \"${READLINE_LINE:0:$READLINE_POINT} $(awk -F= '{print $1}' <<<"${term:-''}" \
        | sed 's/,$//') ${READLINE_LINE:$READLINE_POINT}\")"
 fi
  READLINE_POINT=$(( ${#term} + READLINE_POINT ))
unset term
}

termfilter () {
    Fzvar="$@"
    local Fzvar
    query="$Fzvar:-"command rg {}"j
fd -uu  . -t f --full-path /usr/share/terminfo -x rg --files-with-matches "\${_query:-"${1:-"/E}"}"

}

fztin () {
if [[ -z "$1" ]]; then
Fvar="."; else
Fvar="$1"
fi
local query
_query "$@"
termfilter  \
  | awk -F/ '{print  $NF}' \
  | sort -u \
  | fzf --bind="alt-p:execute:echo $(infocmp {}) >> $HOME/tmp/{}.tmp" \
  --preview-window "right:85:wrap" \
  --preview="cnat; infocmp {} -l ";
}

changeterm () {
local _termchoice
eval "${_termchoice=+:$(fztin "$@")}" | fzfcmp
}

bind -x '"\et": fzfcmp'
#bind -x '"\em": changeterm  '

Alt+功能M仍在进行中,但它将打印所有可用的终端,然后一旦您选择一个终端,它将切换到另一个命令,以便您可以看到哪个终端具有您正在查找的命令行转义序列。

相关内容