How to reorder tmux windows

tmux

In screen, I can just type C-a :number 0 to move a window to the top of the window list and push all the other windows down one. What's the equivalent command sequence for tmux? I looked at the man page, but I'm finding it confusing on this point.

Best Answer

The swap-window command is closest to what you want.

"Prefix :" (that is Ctrl+B, : by default) brings you to the tmux-command prompt. There you enter:

swap-window -s 3 -t 1

to let window number 3 and window number 1 swap their positions.

To swap the current window with the top window, do:

swap-window -t 0

In the unlikely case of having no window at index 0, do:

move-window -t 0

(if base-index is 0, as it is by default). Command move-window -t <NUMBER> is by default bound to Ctrl+B, ..

You can bind that command to a key (T for "top" for example) by adding the following to your ~/.tmux.conf:

bind-key T swap-window -t 0
Related Question