更新时间:2023-12-03 09:19:58
绑定'\\ E ^ M:FOOBAR'
绑定逃生 - 输入,无法进入。你只是想
绑定'^ M:FOOBAR'
^ M
必须是实际控制字符,而不是 ^
和 M
。比较容易的类型是
绑定'\\ C-M:FOOBAR'
So I learned how to use bind yesterday.
By typing Ctrl+v followed by a key in the terminal, I get a raw character that represents the key. For example: Ctrl+v followed by Esc returns ^[
My question is, how can I bind the "enter key". The Enter Key returns "^M" but when I type the command
bind '"\e^M":"foobar"'
pressing the enter key does not result in foobar being typed in my terminal.
bind '"\e^M":"foobar"'
binds Escape-Enter, not Enter. You just want
bind '"^M":"foobar"'
^M
must be the actual control character, not ^
and M
. A little easier to type is
bind '"\C-M":"foobar"'