Session ManagementPrefix + :new (command mode)
new-session
Short form: new
Create a new session. If run from inside tmux, the new session is created but not attached. The new session is grouped with the session specified by -t if given, sharing windows and the current window.
Synopsis
bash
tmux new-session [-AdDEPX] [-c start-directory] [-e environment] [-f flags] [-F format] [-n window-name] [-s session-name] [-t group-name] [-x width] [-y height] [shell-command]Options
| Flag | Description |
|---|---|
| -A | Attach to existing session if it exists, otherwise create new |
| -d | Don't attach to the new session |
| -D | Detach any other clients attached to the session |
| -s session-name | Specify the session name |
| -n window-name | Name the initial window |
| -c start-directory | Specify starting directory |
| -t group-name | Group with an existing session |
| -x width | Set window width |
| -y height | Set window height |
Examples
Create a new session with default name
bash
tmux new-sessionCreate a session named 'dev'
bash
tmux new -s devCreate session 'work' with window named 'editor'
bash
tmux new -s work -n editorCreate session starting in specific directory
bash
tmux new -s project -c ~/code/myprojectAttach to 'main' if it exists, otherwise create it
bash
tmux new -A -s mainCreate a detached session (runs in background)
bash
tmux new -d -s backgroundDefault Keybinding
Prefix + :new (command mode)
Default prefix is Ctrl+b
Pro Tips
- •Use -A flag to create or attach in one command - perfect for scripts
- •The -d flag is useful for creating sessions in startup scripts
- •Session names should be descriptive and short for easy switching