Edouard
Edouard

Reputation: 175

tmux 1.7 move window

I just update to tmux 1.7 and in the man pages there is a new option for using movew: -r which says

move-window [-rdk] [-s src-window] [-t dst-window] (alias: movew) This is similar to link-window, except the window at src-window is moved to dst-window. With -r, all windows in the session are renumbered in sequential order, respecting the base-index option.

If I am having 3 windows in the session: 1 2 3 and I try this command from window 1:

prefix : movew -r -t 4

it gives the error:

session not found: 4

Doesn't this just move window 1 to window 4 and rename the windows? I'm not trying to move it to a new session, just a new window in the same one.

Upvotes: 5

Views: 4924

Answers (1)

Chris Johnsen
Chris Johnsen

Reputation: 224949

The documentation does not explicitly say this, but when you use -r, the argument to -t is interpreted as a session specifier, not a window specifier.

Thus, move-window -r -t 4 tells tmux to renumber all the windows in the session named/matching the string “4”.

It sounds like you can accomplish what you want* with two commands (assuming that 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 escape the semicolon (so that the second command is not simply executed immediately after the initial bind command):

bind-key : move-window -t 4 \; move-window -r

Also, if you normally maintain a “gapless” sequence of window numbers (e.g. you have the renumber-windows option enabled), then you can replace the 4 with : and the command pair will work for any number of windows (not just 3 or fewer): : as a destination window specifier 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 transform a set of windows like 1:A, 2:B, 3:C to 1:B, 2:C, 3:A (i.e. move window #1 (“A”) to the end and renumber them all so that you have 1–3 again instead of 2–4).

Upvotes: 7

Related Questions