我不理解bash中bind -P的输出

时间:2012-06-08 19:51:16

标签: bash

我不理解bind -P命令的输出。 字符是什么意思 -

"\C-g", "\C-x\C-g", "\e\C-g 
 "\e-", "\e0", "\e1", "\e2", "\e3", ...

请解释一下。

谢谢!

2 个答案:

答案 0 :(得分:3)

  • "\C-g" - Ctrl - g - 中止
  • "\C-x\C-g" - Ctrl - x - Ctrl - g - 中止
  • "\e\C-g - Esc - Ctrl - g - 中止
  • "\e-" - Esc - - - 开始计数参数的负数
  • "\e0" - Esc - 0 - 计数参数的数字
  • "\e1" - Esc - 1 - 相同
  • "\e2" - Esc - 2 - 相同
  • "\e3" - Esc - 3 - 相同

有关详细信息,请参阅man readline

答案 1 :(得分:2)

根据bash的man page-P开关执行此操作:

List current Readline function names and bindings. 

Readline也是library integrated with bash(通常)。因此,-P开关中的绑定是运行关联的readline函数所必需的键盘组合。所以,例如:

... snip ...
beginning-of-line can be found on "\eOH", "\e[H".
call-last-kbd-macro is not bound to any keys
capitalize-word is not bound to any keys
character-search is not bound to any keys
character-search-backward is not bound to any keys
clear-screen is not bound to any keys
complete can be found on "\C-i".
... snip ...

这表明函数complete绑定到组合"\C-i",它是control-i的简写。 \C等字符是显示为控制代码的元键。