在GNU Screen中,我想通过调整.screenrc文件将默认的命令绑定改为Alt-s,而不是默认的C-a。原因是我使用emacs,因此GNU Screen绑定了C-a键,将“C-a”发送给emacs变得很麻烦(正如@Nils所说,要发送“C-a”,我应该输入“C-a a”),在bash shell中也是如此,我可以将转义字符更改为C-,但其中一些已经映射到了emacs中,而其他组合键不像ALT-s那样容易。如果有人已经完成了ALT键映射,请告诉我。
在GNU Screen中,我想通过调整.screenrc文件将默认的命令绑定改为Alt-s,而不是默认的C-a。原因是我使用emacs,因此GNU Screen绑定了C-a键,将“C-a”发送给emacs变得很麻烦(正如@Nils所说,要发送“C-a”,我应该输入“C-a a”),在bash shell中也是如此,我可以将转义字符更改为C-,但其中一些已经映射到了emacs中,而其他组合键不像ALT-s那样容易。如果有人已经完成了ALT键映射,请告诉我。
可以使用寄存器和:bindkey命令来解决:escape命令的限制问题。只需将以下内容放入.screenrc文件中:
# reset escape key to the default
escape ^Aa
# auxiliary register
register S ^A
# Alt + x produces ^A and acts as an escape key
bindkey "^[x" process S
## Alt + space produces ^A and acts as an escape key
# bindkey "^[ " process S
请查看http://adb.cba.pl/gnu-screen-tips-page-my.html#howto-alt-key-as-escape
根据我对man screen
的阅读,看起来 screen
可以用于命令绑定的唯一元字符是 CTRL
:
从我阅读man screen
得出结论,screen
似乎只能使用CTRL
作为命令绑定的特殊字符:
escape xy
Set the command character to x and the character generating a literal
command character (by triggering the "meta" command) to y (similar to
the -e option). Each argument is either a single character, a two-character
sequence of the form "^x" (meaning "C-x"), a backslash followed by an octal
number (specifying the ASCII code of the character), or a backslash followed
by a second character, such as "\^" or "\\". The default is "^Aa".
如果在emacs中有一些映射你从不使用,即使它很不方便,比如 C-|
,那么你可以使用终端输入管理器将ALT-X
重新映射到它,让你使用ALT
绑定,但这可能有点hackish。
escape ^||
bindkey "^[x" command
^[x
如何转换为 Alt-x
,其中 ^
表示 Ctrl
(我不确定)?[
是否表示 Alt
?谢谢。 - Leo$ echo -n ^QM-x | perl -ne 'printf "%lo\n", ord($_)'
^Q是readline中的引用插入命令(它直接插入您键入的内容而不尝试解释它),而M-x是字面意义上的Alt-X。
我也是Emacs用户。
我发现最好的解决方案是一个包含以下内容的~/.screenrc文件:
# C-a :source .screenrc
escape ^gg
实时更新在这里:https://gist.github.com/1058111
我在我的.screenrc
文件中已经有多年了:
escape ^Zz
这个对我来说现在已经成为了肌肉记忆。
不知怎么的,我最近不得不和别人的配置共享屏幕,结果现在总是不停地停止进程(bash ^Z
)……真的很烦人……