Your productivity will increase by many folds if you can organise tmux the right way. Well, tmux sessions are the right way to do so.
The first step to organising these sessions is naming them appropriately, based on what processes they manage.
This is the continuation of the tmux series, right from attaching and detaching sessions.
Rename a session outside tmux
By default, tmux creates sessions just like it indexes all its panes and windows with numbers (from 0).
When you are in the command line outside tmux, you can still perform operations on sessions. This can come in handy when you are automating session creation itself – using scripts or configs.
To know what session to rename, check the ongoing sessions by running the command
tmux ls
To rename a session, you can use the following command:
tmux rename-session -t <target-session> <new-name>
where <target-session>
is the current name, probably a number, of the session to be renamed.
Rename a session within tmux
You can rename it while already in a session by the following shortcut:
[Ctrl+B] + $
Here’s an example of how to do the same:
Conclusion
Renaming your tmux sessions is a simple but powerful step toward keeping your terminal environment organized and efficient. Proper session names help you quickly identify and switch between different tasks.
When you are done with a session, it might make sense to terminate it. The next one in this series deals with how you can kill sessions.