irritable_phd_syndrome
irritable_phd_syndrome

Reputation: 5087

Swapping panes in tmux depends on active window

I am running tmux on a RHEL 8.6 server. I ssh into the server from an OSX 13.6 Mac running Iterm2-3.4.20.

Here is my ~/.tmux.conf

$ cat ~/.tmux.conf
unbind C-b
set-option -g prefix C-a
set -g default-terminal "screen-256color"
set -g history-limit 5000
#set-window-option -g mode-keys vi
setw -g mode-keys vi
set-option -g allow-rename off

After logging in, I attach to my tmux window. It has 3 tmux panes. If I'm on pane 0, I can swap panes 0 and 1 (i.e. :swap-pane -s1 -t0). If I'm on pane 1, the exact same command does not switch. Also, from pane 1 :swap-pane -s0 -t1 does not work either.

From the tmux man page

"target-pane (or src-pane or dst-pane) may be a pane ID" (edited) "

These commands should work. I tried it from OSX's Terminal.app and observed the same behavior. It seems that swapping panes is dependent on which pane is active should make a difference.

QUESTION :

  1. How do I swap panes 0 and 1 when the active pane is 1?

Upvotes: 0

Views: 252

Answers (1)

pynexj
pynexj

Reputation: 20797

I suspect when you are talking about "pane 0" and "pane 1" you are actually meaning "window 0" (window with index 0) and "window 1" (window with index 1) so you can use swap-window:

swap-window -s :0 -t :1

And "window id" is not the same thing as "window index". "Window id" is a string like @1 which does not change for the lifetime of the window but "window index" is a relative number which may change when you create/kill/move windows. This also applies for panes.

This is from man tmux:

Sessions, window and panes are each numbered with a unique ID; session IDs are prefixed with a $, windows with a @, and panes with a %. These are unique and are unchanged for the life of the session, window or pane in the tmux server.

Upvotes: 1

Related Questions