Renumber windows to remove gap in the sequence
windows
// what it does
`move-window -r` renumbers every window in the session into a gapless sequence, closing the holes left by killed windows. It renumbers the current session (or the one named via `-s`/`-t`) and respects the base-index option, so numbering starts at 1 when base-index is 1. Run it once to tidy up scattered window numbers.
// tmux command
: move-window -r: movew -r// gotcha
It's a one-shot cleanup — to renumber automatically whenever a window closes, set `renumber-windows on` in tmux.conf instead.