通过 SSH 连接时,如何在 cygwin 的 gnu screen 中使用 F1-F12 键切换屏幕?
我正在 Mac OS X 中的终端应用程序中通过 SSH 连接到运行 cygwin 的桌面。我已经在 cygwin 端启动了 screen,并且可以通过 SSH 会话连接到它。此外,我在 .screenrc 文件中有以下内容:
bindkey -k k1 select 1 # F1 = screen 1
bindkey -k k2 select 2 # F2 = screen 2
bindkey -k k3 select 3 # F3 = screen 3
bindkey -k k4 select 4 # F4 = screen 4
bindkey -k k5 select 5 # F5 = screen 5
bindkey -k k6 select 6 # F6 = screen 6
bindkey -k k7 select 7 # F7 = screen 7
bindkey -k k8 select 8 # F8 = screen 8
bindkey -k k9 select 9 # F9 = screen 9
bindkey -k F1 prev # F11 = prev
bindkey -k F2 next # F12 = next
但是,当我在屏幕上启动多个窗口并尝试通过功能键在它们之间切换时,我得到的只是一声蜂鸣声。
我已经尝试了 $TERM 的各种设置(例如 ansi、cygwin、xterm-color、vt100),它们似乎并没有真正影响任何东西。
我已经验证终端应用程序实际上正在发送我期望的功能键的转义序列,并且我的 bash shell(在屏幕内运行)正在接收它。例如,对于 F1,它发送以下内容(hexdump 是我编写的一个 perl 脚本,它在 binmode 下接受 STDIN 并将其输出为十六进制/ascii 转储):
% hexdump
[press F1 and then hit ^D to terminate input]
00000000: 1b4f50 .OP
如果一切正常,我认为 bash 不应该接收转义符序列,因为屏幕应该捕获它并将其转换为命令。
如何让功能键发挥作用?
I'm connecting to a desktop running cygwin via SSH from the terminal app in Mac OS X. I have already started screen on the cygwin side and can connect to it over the SSH session. Furthermore, I have the following in the .screenrc file:
bindkey -k k1 select 1 # F1 = screen 1
bindkey -k k2 select 2 # F2 = screen 2
bindkey -k k3 select 3 # F3 = screen 3
bindkey -k k4 select 4 # F4 = screen 4
bindkey -k k5 select 5 # F5 = screen 5
bindkey -k k6 select 6 # F6 = screen 6
bindkey -k k7 select 7 # F7 = screen 7
bindkey -k k8 select 8 # F8 = screen 8
bindkey -k k9 select 9 # F9 = screen 9
bindkey -k F1 prev # F11 = prev
bindkey -k F2 next # F12 = next
However, when I start multiple windows in screen and attempt to switch between them via the function keys, all I get is a beep.
I have tried various settings for $TERM (e.g. ansi, cygwin, xterm-color, vt100) and they don't really seem to affect anything.
I have verified that the terminal app is in fact sending the escape sequence for the function key that I'm expecting and that my bash shell (running inside screen) is receiving it. For example, for F1, it sends the following (hexdump is a perl script I wrote that takes STDIN in binmode and outputs it as a hexadecimal/ascii dump):
% hexdump
[press F1 and then hit ^D to terminate input]
00000000: 1b4f50 .OP
If things were working correctly, I don't think bash should receive the escape sequence because screen should have caught it and turned it into a command.
How do I get the function keys to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您有更奇怪的设置(例如 Windows -> PuTTY -> Linux),其中标准
bindkey -k
解决方案无法正常工作,您可以使用showkey
code> 命令:查找从击键到键代码的映射。在我的特定情况下,将它们放入
~/.screenrc
中可以达到目的:If you have a more bizarre setup (e.g. Windows -> PuTTY -> Linux) where the standard
bindkey -k
solution doesn't quite work right, you can use theshowkey
command:to find the mapping from keystrokes to key codes. In my particular case, putting these in
~/.screenrc
did the trick:经过大量的实验,我能够通过将以下行添加到我的 .screenrc 中来使其工作:
With a great deal of experimentation, I was able to get it to work by adding the following lines to my .screenrc:
我在 macOS 上使用 iTerm。这对我有用:
将这 4 行放入您的 .screenrc 中。
答案受到 Mikey 答案的启发。
I am using iTerm on macos. This works for me:
Put these 4 lines in your .screenrc.
Answer inspired by Mikey's answer.