Start a new session or attach to an existing session named mysession

sessions

// what it does

This is the idempotent attach-or-create idiom: `-A` tells `new-session` to behave like `attach-session` when a session named `mysession` already exists, and to create it fresh otherwise. Because the outcome is the same whether or not the session exists, the command is safe to drop in a shell profile, tmux launcher script, or SSH login hook. It's the cleanest way to guarantee you land in a specific session without checking first.

// shell

$ tmux new-session -A -s mysession

// gotcha

Without `-D`, `-A` attaches as an additional client and shares the session with anyone already connected — both clients see the same windows, and the display size follows the `window-size` option (default `latest`) rather than your terminal alone. Add `-D` (`new-session -A -D -s mysession`) to detach the other clients first.