我试图通过在inputrc中为元键添加一个绑定来扩展readline。我正在使用终端(OSX)
理想情况下,我想添加"\M-h": "\C-w"
但是,我似乎不能绑定任何元键。我在终端中有一个选项,它将我的选项键作为元。因此,我可以很好地输入M-b。在我的inputrc中绑定到它不起作用。
我试着用sed -nl记录转义序列被发送到我的终端。按M-x输出^[h,但是像"^[h":"\C-w"这样的绑定不起作用。帮助是非常感谢的。
编辑:这里的是读行文档中的样本文件,它展示了如何根据发送的ansi转义键绑定。也许我没有映射到正在发送的正确的转义键,有比sed更好的检查方法吗?
发布于 2015-03-19 16:54:23
我问题的解决方案是以下绑定:"\eh": "\C-w"
\e是读行到Esc键的映射。
在缺少元键的键盘上,没有统一的表示方法。因此:
Mac终端的"option“选项只意味着>”带有ESC的前缀“- 克里斯·佩奇
因此,终端将Meta视为选项,后者将Esc发送到读行。
发布于 2015-03-19 12:14:05
这是绑定它的正确方法吗?不应该是键名:函数名吗?但并没有把它洗劫一空。
从手册页:
Readline Key Bindings
The syntax for controlling key bindings in the inputrc file is simple. All that is required is the name of the command or the text of a macro and a key sequence to which
it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with Meta- or Control- prefixes, or as a key sequence.
When using the form keyname:function-name or macro, keyname is the name of a key spelled out in English. For example:
Control-u: universal-argument
Meta-Rubout: backward-kill-word
Control-o: "> output"
In the above example, C-u is bound to the function universal-argument, M-DEL is bound to the function backward-kill-word, and C-o is bound to run the macro expressed on
the right hand side (that is, to insert the text \u2018\u2018> output\u2019\u2019 into the line).
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"
In this example, C-u is again bound to the function universal-argument. C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~ is bound to insert the text
\u2018\u2018Function Key 1\u2019\u2019.此外,您还可以考虑查看/etc/inputrc,它有默认的绑定。
https://stackoverflow.com/questions/29138548
复制相似问题