How to make tmux number windows and panes from 1?

By Romain Dorgueil

Short answer

# ~/.tmux.conf
set  -g base-index 1        # windows start at 1
setw -g pane-base-index 1   # panes start at 1
set  -g renumber-windows on # keep the list contiguous when a window closes

By default tmux numbers windows and panes from 0, so the first window answers to prefix 0, a key at the far right of the number row. Setting base-index and pane-base-index to 1 lines the numbering up with the keyboard: prefix 1 selects the first window, prefix 2 the second.

Details

base-index is a session option and controls window numbering; pane-base-index is a window option, so it is set with setw (or set -w). Both only affect windows and panes created after the option is set, so put them in ~/.tmux.conf and they apply from the start of every session.

renumber-windows on is the natural companion. Closing a window in the middle of the list leaves a gap, so indexes drift to something like 1 3 6; with this option tmux repacks them to 1 2 3 on every close, and prefix 1, prefix 2 keep landing where you expect.

One consequence worth knowing: shifting the first pane to 1 changes how numeric pane targets read. A bare number in a pane target is the pane of the current window when that pane exists, so after this change tmux swap-pane -s 1 refers to your new first pane. When a target has to be unambiguous, prefer a pane id (%3) or a window.pane form over a bare number.

Verified on tmux 3.2a.

Related