Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux 1.7 move window

Tags:

tmux

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.

like image 244
Edouard Avatar asked Oct 14 '12 22:10

Edouard


People also ask

How do I move a tmux window?

Pressing Ctrl+Shift+Left (will move the current window to the left.

How do I rearrange tmux panes?

To change the layout of panes in a Tmux windows, press <prefix><space> . It will change between different layouts. We may also use command select-layout (or selectl for short) instead.

How do I renumber a tmux window?

Looks like you need this: 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. Show activity on this post.

How do I use tmux command line?

To enter Command mode, press Prefix : (the colon) from within a running tmux session. The status bar changes color and we get a command prompt that indicates that we can type our command.


1 Answers

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).

like image 181
Chris Johnsen Avatar answered Nov 13 '22 05:11

Chris Johnsen