You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在tmux choose-tree中按数字键选中窗口而非直接进入

tmux choose-tree 数字键仅选中不跳转配置

问题复现步骤

  • 执行以下命令创建包含3个窗口的tmux会话:
tmux
tmux new-window
tmux new-window
  • 执行tmux choose-tree命令,或按下快捷键Ctrl+b w调出窗口列表,显示内容如下:
(0) - 0: 3 windows (attached)
(1) ├─> 0: zsh
(2) ├─> 1: zsh-
(3) └─> 2: [tmux]*
  • 默认配置下,按下数字键2时,tmux会直接选中并跳转至1: zsh窗口,无法提前预览窗口内容。

预期效果

在choose-tree界面按下数字键时,仅选中对应窗口而非直接进入,效果与开启set -g mouse on配置后鼠标点击窗口的选中效果一致:例如按下2时仅选中1: zsh窗口,可预览窗口内容后再决定是否进入。

实现方法

choose-tree模式下数字键默认绑定的命令会在选中条目后直接触发跳转动作,只需修改按键绑定,替换为纯选中条目的命令即可达到预期效果。
将以下配置写入~/.tmux.conf文件:

# choose-tree 界面按数字键仅选中不跳转
bind -T choose-tree 0 select-item -t 0
bind -T choose-tree 1 select-item -t 1
bind -T choose-tree 2 select-item -t 2
bind -T choose-tree 3 select-item -t 3
bind -T choose-tree 4 select-item -t 4
bind -T choose-tree 5 select-item -t 5
bind -T choose-tree 6 select-item -t 6
bind -T choose-tree 7 select-item -t 7
bind -T choose-tree 8 select-item -t 8
bind -T choose-tree 9 select-item -t 9

配置写入后,在tmux会话内执行tmux source-file ~/.tmux.conf重载配置即可生效。
生效后操作逻辑:

  • 按0-9数字键:仅选中对应序号的条目,停留在choose-tree界面,可实时预览选中窗口的内容
  • 按Enter键:确认进入当前选中的窗口/会话
  • 按q键:退出choose-tree界面返回原窗口

若使用tmux 3.2以下版本,将配置中的select-item替换为select-pane即可,逻辑完全一致。


内容的提问来源于stack exchange,提问作者Cyrus Yip

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.28 09:45:18