我如何告诉 tmux 在我杀死一个窗格后自动调整窗格大小?
How do I tell tmux to automatically resize panes after I kill a pane?
当我有三个等宽的窗格时:
|------|------|------|
我杀了一个窗格,我的窗格可能看起来像这样:
|------|------------|
但我希望它们看起来像这样,自动:
|--------|--------|
要手动执行此操作,我使用 select-layout even-horizontal
和热键。
也许有一种方法可以在窗格被杀死后自动进入tmux select-layout even-horizontal
。
As i_v_harish pointed out in his comment, this is possible from tmux 2.3+ 引入了命令挂钩。
窗格可能因以下原因之一而关闭。
- 窗格已杀死
- 与
kill-pane
(默认绑定到+x)
- 窗格已退出
- 窗格中的命令 运行 终止(例如,如果它是 shell 并且用户键入
exit
或按 Ctrl+ d)
可以将以下行添加到 ~/.tmux.conf
以涵盖这两个用例。
set-hook -g after-kill-pane 'select-layout even-horizontal'
set-hook -g pane-exited 'select-layout even-horizontal'
挂钩在 manual 中进行了描述。
tmux allows commands to run on various triggers, called hooks. Most tmux commands have an after hook and there are a number of hooks not associated with commands.
A command's after hook is run after it completes, except when the command is run as part of a hook itself. They are named with an ‘after-’ prefix.
除了 even-horizontal
之外,您还可以 select 多种不同的布局。
偶数水平
+---+---+---+---+---+
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---+---+---+---+---+
偶数垂直
+-------------------+
| |
+-------------------+
| |
+-------------------+
| |
+-------------------+
主水平线
+---+---+---+---+---+
| |
| |
+---+---+---+---+---+
| | | | | |
| | | | | |
+---+---+---+---+---+
主要垂直
+------+------------+
| | |
| +------------+
| | |
| +------------+
| | |
+------+------------+
平铺
+---------+---------+
| | |
+---------+---------|
| | |
+---------+---------+
| |
+-------------------+
当我有三个等宽的窗格时:
|------|------|------|
我杀了一个窗格,我的窗格可能看起来像这样:
|------|------------|
但我希望它们看起来像这样,自动:
|--------|--------|
要手动执行此操作,我使用 select-layout even-horizontal
和热键。
也许有一种方法可以在窗格被杀死后自动进入tmux select-layout even-horizontal
。
As i_v_harish pointed out in his comment, this is possible from tmux 2.3+ 引入了命令挂钩。
窗格可能因以下原因之一而关闭。
- 窗格已杀死
- 与
kill-pane
(默认绑定到+x)
- 与
- 窗格已退出
- 窗格中的命令 运行 终止(例如,如果它是 shell 并且用户键入
exit
或按 Ctrl+ d)
- 窗格中的命令 运行 终止(例如,如果它是 shell 并且用户键入
可以将以下行添加到 ~/.tmux.conf
以涵盖这两个用例。
set-hook -g after-kill-pane 'select-layout even-horizontal'
set-hook -g pane-exited 'select-layout even-horizontal'
挂钩在 manual 中进行了描述。
tmux allows commands to run on various triggers, called hooks. Most tmux commands have an after hook and there are a number of hooks not associated with commands.
A command's after hook is run after it completes, except when the command is run as part of a hook itself. They are named with an ‘after-’ prefix.
除了 even-horizontal
之外,您还可以 select 多种不同的布局。
偶数水平
+---+---+---+---+---+
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---+---+---+---+---+
偶数垂直
+-------------------+
| |
+-------------------+
| |
+-------------------+
| |
+-------------------+
主水平线
+---+---+---+---+---+
| |
| |
+---+---+---+---+---+
| | | | | |
| | | | | |
+---+---+---+---+---+
主要垂直
+------+------------+
| | |
| +------------+
| | |
| +------------+
| | |
+------+------------+
平铺
+---------+---------+
| | |
+---------+---------|
| | |
+---------+---------+
| |
+-------------------+