使用putty时,当byobu从配置文件自动启动时,alt-left/right是不同的

使用putty时,当byobu从配置文件自动启动时,alt-left/right是不同的

当从 Windows 计算机上使用 Putty 启动到 Debian 和 Ubuntu 计算机(至少在我的情况下)的会话时,alt-left/right就像在命令行上按单词移动一样。 (通常这也可以在 Linux 系统上通过 实现ctr-left/right)。

然而,当我开始使用 Byobu 后,将 Byobu 设置为自动启动(使用 F9 菜单),该功能alt-left/right不再起作用。相反,当使用Ctrl-V它输出原始字符时,

 ^[[1;3C

- 发送时alt-right。然而,当 byobu 在登录时没有自动启动,而是在登录后手动启动时,我推断它会发送,

^[^[[C

它被默认的 inputrc 配置捕获,因此它被翻译为按单词移动。

Putty、主机/终端/byobu 之间的机制是什么,可以在接收到的命令中产生这种差异?

答案1

byobu 只是 tmux 的包装,它负责您所看到的行为。 tmux 正在尝试将“键”转换为 xterm 编码修改后的特殊键的字符序列。在手册中,记录了这一点:

         xterm-keys [on | off]
                 If this option is set, tmux will generate xterm(1) -style
                 function key sequences; these have a number included to
                 indicate modifiers such as Shift, Alt or Ctrl.  The
                 default is off.

尽管在新/最近的版本中,据报道默认值是。这暴露了一个问题,在这个提交消息中可以看到:

commit d52f579fd5e7fd21d7dcf837780cbf98498b10ce
Author: nicm <nicm>
Date:   Sun May 7 21:25:59 2017 +0000

    Up to now, tmux sees \033\033[OA as M-Up and since we turned on
    xterm-keys by default, generates \033[1;3A instead of
    \033\033[OA. Unfortunately this confuses vi, which doesn't understand
    xterm keys and now sees Escape+Up pressed within escape-time as Escape
    followed by A.

    The issue doesn't happen in xterm itself because it gets the keys from X
    and can distinguish between a genuine M-Up and Escape+Up.

    Because xterm can, tmux can too: xterm will give us \033[1;3A (that is,
    kUP3) for a real M-Up and \033\033OA for Escape+Up - in fact, we can be
    sure any \033 preceding an xterm key is a real Escape key press because
    Meta would be part of the xterm key instead of a separate \033.

    So change tmux to recognise both sequences as M-Up for its own purposes,
    but generate the xterm version of M-Up only if it originally received
    the xterm version from the terminal.

    This means we will return to sending \033\033OA instead of the xterm key
    for terminals that do not support xterm keys themselves, but there is no
    practical way around this because they do not allow us to distinguish
    between Escape+Up and M-Up. xterm style escape sequences are now the de
    facto standard for these keys in any case.

    Problem reported by jsing@ and subsequently by Cecile Tonglet in GitHub
    issue 907.

相关内容