我试图直接在 tmux 中当前选定的窗格下获取窗格的索引,以便我可以tmux run-shell从 vim 调用该窗格。
假设我有一个如下所示的 tmux 窗格布局:
|---------------------------|
| | |
| 0 | 1 |
| | |
|---------------------------|
| |
| 2 |
| |
|---------------------------|
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过运行以下命令获取当前的窗格编号:
tmux list-panes | grep "active" | cut -d':' -f1
对于这种情况,我们会说它是0
这是我想到的第一个获取索引的解决方案:
#!/bin/bash
CUR_PANE=$(tmux list-panes | grep "active" | cut -d':' -f1)
tmux select-pane -D
UNDER_PANE=$(tmux list-panes | grep "active" | cut -d':' -f1)
tmux select-pane -U
# In case the script is used on the bottom …Run Code Online (Sandbox Code Playgroud)