Tmux 键绑定到左或右交换窗格

Hel*_*Mad 7 tmux

我知道:swap-pane -U并且:swap-pane -D会向上或向下交换窗格,但我想要一个键绑定来左右交换窗格。

我能想到的唯一方法是首先确定当前窗格的窗格索引,然后运行:select-pane -Ror-L并确定其索引,最后运行:swap-pane -s (first pane index) -t (second pane index).

我只是不确定如何在其中执行此操作.tmux.conf- 是否可以使用在另一个命令中返回某些内容的子命令?

例如,这样的事情:

bind-key -n C-{ swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -L'**

bind-key -n C-} swap-pane -s **get current pane ID** -t **get pane ID of 'select-pane -R'**

小智 14

:bind-key -n C-{ select-pane -L \; swap-pane -s '!'

这应该告诉 tmux 选择左窗格,然后与之前活动的窗格交换。

此外,swap-pane -s {right-of}似乎工作。
以下是引用其他窗格的方法列表:

{last} !       The last (previously active) pane
{next} +       The next pane by number
{previous} -   The previous pane by number
{top}          The top pane
{bottom}       The bottom pane
{left}         The leftmost pane
{right}        The rightmost pane
{top-left}     The top-left pane
{top-right}    The top-right pane
{bottom-left}  The bottom-left pane
{bottom-right} The bottom-right pane
{up-of}        The pane above the active pane
{down-of}      The pane below the active pane
{left-of}      The pane to the left of the active pane
{right-of}     The pane to the right of the active pane
Run Code Online (Sandbox Code Playgroud)

请参阅联机手册页以供参考。