How to navigate between tmux windows?

By Romain Dorgueil

Short answer

tmux next-window       # go to the next window
tmux previous-window   # go to the previous window
tmux last-window       # toggle with the previously active window

From the keyboard with the default prefix, prefix n goes to the next window, prefix p to the previous one, and prefix l (lowercase L) toggles back and forth with the window you were on before.

Details

A tmux session holds a list of windows, each with its own number. next-window and previous-window walk that list one step at a time, and they wrap: from the last window, n loops back to the first.

The one worth a reflex is prefix l, bound to last-window. It does not step through the list, it jumps straight back to the window that was active just before the current one. So when you flip to another window to check something and want to return, it is one keystroke each way, no matter how far apart the two windows sit in the list. It is the window-level equivalent of prefix ;, which toggles the last active pane.

Verified on tmux 3.2a. With three windows (0, 1, 2) and 2 active, last-window jumps to 0, and a second last-window returns to 2. From window 0, next-window goes to 1 and previous-window returns to 0. The default bindings are prefix n to next-window, prefix p to previous-window, and prefix l to last-window.

Related