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: set -g renumber-windows on closes the gap when you close a window

Tmux
~/tips/tip-tmux-renumber-windows

set -g renumber-windows on

Renumbers tmux windows automatically so there is no gap after one is closed.

Close window 1 of three and you are left with 0 and 2, which breaks the habit of jumping by number.

set -g renumber-windows on

With the option on, window 2 becomes 1 as soon as the old 1 closes. tmux show -gv renumber-windows prints on when it is active.

Without it, closing the middle window leaves a hole in the numbering. With windows 0, 1 and 2, closing window 1 leaves 0 and 2, and a shortcut that you used for the third window now points to the wrong place or to nothing.

The option keeps the numbers dense and in order, so the status bar always reads 1, 2, 3 without a gap. It pairs naturally with base-index 1. If you prefer stable numbers over tidy ones, leave it off, because then a window keeps its number until you move it yourself with move-window.

Numbers you memorised may move under you after a close.

Try it in a throwaway session: tmux new -s scratch, and close it afterwards with tmux kill-session -t scratch.

Further reading: tmux manual page (OpenBSD, official), tmux wiki: Getting Started (official), On this site: Ctrl-b l jumps back to the window you were just in, On this site: Ctrl-b w shows every window of every session as a tree

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