我想在 GNU Screen 中创建一个自定义键绑定,当按下某个键(例如F1)时,相当于先按Enter然后再按 Screennext
命令。
我知道bindkey
可以将按键绑定到屏幕命令,但它也可以用于触发其他一些命令行输入,例如仅按下“enter”键?
答案1
是的,您可以使用stuff
screen 命令。从手册页screen
:
stuff [string] Stuff the string string in the input buffer of the current window. This is like the "paste" command but with much less overhead. Without a paramter, screen will prompt for a string to stuff. You cannot paste large buffers with the "stuff" command. It is most useful for key bindings. See also "bindkey".
此外,在手册页中您还可以看到以下示例:
bindkey -k k1 select 1 Make the "F1" key switch to window one. bindkey -t foo stuff barfoo Make "foo" an abbreviation of the word "barfoo". Timeout is disabled so that users can type slowly.
例如,您可以将以下行添加到$HOME/.inputrc
文件中以将F1写入绑定\n
到输入缓冲区(相当于按Enter)。
bindkey -k k1 stuff "\n"