brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tmux swap-window -t 1 trades the places of two windows

Tmux
~/tips/tip-tmux-swap-window

tmux swap-window -s 3 -t 1

Swaps the positions of two tmux windows.

My windows rarely stay in the order I opened them. The editor ends up at 4 while the window I check all the time sits at 2, and I want the busy ones on the left.

swap-window exchanges two windows, so each one takes the position of the other.

tmux swap-window -s 3 -t 1

Window 3 moves to position 1 and the old window 1 moves to position 3. If you leave out -s, tmux uses the current window as the source (or the window with a marked pane, if you marked one with select-pane -m). Inside tmux this is enough:

swap-window -t 1

Type it after Ctrl-b :. The swapped window becomes the current one. Add -d to stay where you are:

tmux swap-window -d -s 3 -t 1

The manual says it is an error if no window exists at the source index. To move a window to a number that is still free, use move-window. With move-window -r tmux renumbers all windows of the session in order, following the base-index option.

The indexes follow base-index as well. If you start counting at 1, window 1 in the examples is the first one on your status bar, and a target that does not exist gives an error.

Further reading: tmux manual

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link