Rename tmux sessions
March 27, 2020 ‐ 2 min read
When you start a new tmux session, by default tmux uses a numerical value to name the session. This isn't all too clear, especially when we're working with multiple tmux sessions at the same time. Ofcourse you can start a named tmux session with
tmux new -s sesh. But the ability to rename either the default name the provided name is convenient once every while.
To rename a tmux session you can use the
tmux rename-session command. With the argument for the
-t option you specify which session is the target to rename. And the second argument is the new name for the session.
$ tmux rename-session -t old_name new_name
The alias for
rename-session is simply
rename. Meaning that you get the same results as above with
tmux rename -t old_name new_name.
When you are in currently in the session you want to rename you can omit the current sessions name. Tmux will assume that your current session needs to be renamed if you don't specify a target with
$ tmux rename-session new_name
This command works outside of tmux too. In that case the most recently used tmux session is renamed.
The rename functionality can be used in the tmux command mode too. To start the command mode use
<prefix> :. Now enter
:rename-window new_name and your current tmux session is renamed to "new_name".
To do the above more quickly you can use a keybinding. By default
:rename-window is binded to the key combination
A great resource for learning more about tmux are its man pages. You can read them online here or from the command-line using the following command:
$ man tmux
Or take a look at this book: