Tmux:绑定Ctrl-`

Jon*_*n Q 5 linux keyboard-shortcuts tmux

我想将 tmux 中的 Ctrl-` 绑定到选择窗格。

我试过: bind -n C-` select-pane -t :.+ 这给了我:unknown key C-`

我也试过: bind -n 'C-`' select-pane -t :.+ 这给了我同样的错误。

然后我尝试了简单的`: bind -n ` select-pane -t :.+ 效果很好(但绑定了`不是C-`。

最令人困惑的是,我尝试了: bind -n `-C select-pane -t :.+ 这出人意料地有效(我必须先按反引号,然后按 ctrl)。tmux 不喜欢 Ctrl-` 中的什么?

Tho*_*key 7

tmux使用此逻辑来处理ctrl修饰符key-string.c(反引号是代码 96):

    /* Convert the standard control keys. */                               
    if (key < KEYC_BASE && (modifiers & KEYC_CTRL) && !strchr(other, key)) {
            if (key >= 97 && key <= 122)
                    key -= 96;
            else if (key >= 64 && key <= 95)
                    key -= 64;
            else if (key == 32)
                    key = 0;
            else if (key == 63)
                    key = KEYC_BSPACE;
            else
                    return (KEYC_NONE);
            modifiers &= ~KEYC_CTRL;
    }
Run Code Online (Sandbox Code Playgroud)

尽管某些应用程序可能会将 64 到 126 的整个范围视为对 有效ctrl,但 tmux 不包括反引号、花括号、竖线和波浪号。可能的原因是它们对键绑定不太有用,因为未修改的键通常用于 shell 脚本中。

另一方面,ctrl-@将具有相同的预期解释,您可以改用它。


小智 6

cat我在某处找到了使用tmux 内部检查转义序列的建议。

  1. 跑步tmux
  2. 跑步cat
  3. 按键C-`

在我的终端上我有^@

所以在我放置的配置中

set -g prefix ^@ 为我工作过roxterm