小编Jeb*_*bby的帖子

如何获取 tmux 中当前窗格下方窗格的索引?

我试图直接在 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)

bash tmux

5
推荐指数
1
解决办法
1487
查看次数

标签 统计

bash ×1

tmux ×1