如何自动重置 tmux window 索引

How to automaticly reset tmux window indexes

比方说,我在 tmux 会话中打开了五个 windows。我关闭了索引 1 处的 window,所以我在索引 0、2、3 和 4 上留下了 windows。有没有办法自动重新排列它们(这样结果将是 0、1 , 2 和 3)?我知道我可以切换 windows 的位置直到我到达那里,还有其他方法吗?

       renumber-windows [on | off]
               If on, when a window is closed in a session, automatically renum-
               ber the other windows in numerical order.  This respects the
               base-index option if it has been set.  If off, do not renumber
               the windows.

把它放在你的 tmux conf 中。

set -g renumber-windows on