带有 Alt<number> 的 tmux 选择窗口

Pha*_*tom 5 keyboard-shortcuts tmux

在 tmux 中选择一个窗口,默认行为是C-b <number>. 我想通过使用 alt+ 来避免使用前缀以进行更快的选择。

我为下一个和上一个窗口做了它,它有效:

 bind -n M-n select-window -n
 bind -n M-p select-window -p
Run Code Online (Sandbox Code Playgroud)

对于通过 id 的选择,我做了同样的事情,但它不起作用:

bind -n M-0 select-window -t 0
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
Run Code Online (Sandbox Code Playgroud)

有没有简单的方法让它工作?

小智 0

正如您在这里所看到的,tmux 不支持数字字符的键绑定。

\n\n

因为我将 tmux 与iTerm一起使用,所以我有解决方法:

\n\n
    \n
  • 在 iTerm -> 首选项 -> 键 -> 键绑定上:我确实将键+数字绑定到特定字符,例如:C-0 -> ; C-1 -> ; ETC
  • \n
  • 在 .tmux.conf 上我确实使用了该字符:bind\xc2\xb7-n\xc2\xb7\xc2\xb7\xe2\x80\xa6
  • \n
\n\n

对于其他终端客户端,我想有一个选项可以以相同的方式映射键,因此只需找到如何映射键即可。

\n