tmux is a terminal multiplexer: persistent sessions, plus
windows and split panes inside a single terminal. The snippets below are verified on tmux
3.2a. The prefix key is assumed to be the default C-b unless stated otherwise.
Cookbook
Create or attach a session (idempotent)
tmux new -A -s name
-A makes new-session behave like attach-session when the session already exists, so there
is no “duplicate session” error. That makes it the right command for scripts and shell startup
files. Add -d to create it detached (or no-op if it is already running).
Tip article: How to create or attach to a tmux session in one command?
Start a named session with a window name and directory
tmux new -d -s projet -n edit -c ~/code/projet
Creates the session projet, names its first window edit, and starts it in ~/code/projet.
-d keeps it detached so the command is scriptable; attach later with tmux attach -t projet.
Tip article: How to start a named tmux session with a window name and a directory?