This is not explicitly stated in the documentation, but when you use -r , the -t argument is interpreted as a session specifier, not a window specifier.
Thus, move-window -r -t 4 tells tmux to renumber all windows in the session with the name / corresponding line "4".
It looks like you can accomplish what you want * with two commands (assuming you have base-index set to 1):
move-window -t 4 ; move-window -r
You can bind a sequence of commands to a key, but you need to avoid a semicolon (so the second command does not just execute immediately after the initial bind command):
bind-key : move-window -t 4 \; move-window -r
In addition, if you usually maintain a βhassle-freeβ sequence of window numbers (for example, you have the renumber-windows option renumber-windows ), you can replace 4 with : and a couple of commands will work for any number (not only 3 or less) : in as the specifier of the destination window means "the first unused window number in the current session" (i.e. 4 if you already have windows 1-3).
* If I understand correctly that you want to convert a set of windows, such as 1: A, 2: B, 3: C to 1: B, 2: C, 3: A (i.e. move window No. 1 ("A ") to the end and renumber them all so that you have 1-3 again instead of 2-4).
source share