How to rename a tmux session or window?
Short answer
tmux rename-session -t old new # rename a session
tmux rename-window new # rename the current window
From inside a session, prefix $ renames the current session and prefix , renames the current
window, each through a prompt.
Details
Names beat numbers once you run more than a couple of sessions: tmux attach -t api is easier to
remember than guessing an index.
Rename a session with prefix $, which opens a prompt pre-filled with the current name. The
shell form is tmux rename-session -t old new (short alias: tmux rename -t old new). The target
-t is optional when you mean the current session.
Rename a window with prefix ,, again through a prompt. The shell form is tmux rename-window new, which acts on the current window by default; target another one with -t.
One side effect worth knowing: by default a window renames itself to follow the running program
(automatic-rename on). The moment you rename a window by hand, tmux turns automatic renaming off
for that window, so your chosen name stays put. If you want fixed names everywhere, set it
globally:
setw -g automatic-rename off
Verified on tmux 3.2a.