I'm aware that :swap-pane -U
and :swap-pane -D
will swap panes up or down, but I'd like a keybinding to swap panes left and right.
The only way I can think of to do this would be to first determine the pane index of the current pane, then run :select-pane -R
or -L
and determine its index, and finally run :swap-pane -s (first pane index) -t (second pane index)
.
I'm just not sure how to do this in .tmux.conf
– is it possible to have subcommands which return something within another command?
For example, something like this:
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'**
Best Answer
:bind-key -n C-{ select-pane -L \; swap-pane -s '!'
This should tell tmux to select the left pane, and then swap with the previously active pane.
Also,
swap-pane -s {right-of}
seems to work.Here is the list of ways to refer to other panes:
See the online man page for reference.