Naming tmux sessions | Generated by AI

Home 2026.04

Question: How to create tmux sessions with a name?

Answer:

To create a tmux session with a custom name, use the -s flag with the tmux new-session command (or its shorthand tmux new).

Basic Command

tmux new-session -s session_name

Example:

tmux new-session -s myproject

This creates a new tmux session named “myproject” and attaches to it immediately.

Shorthand Version

tmux new -s myproject

Additional Useful Options

Common Workflow Examples

  1. Create and attach:
    tmux new -s dev
    
  2. Create detached (useful in scripts or when you want to set up multiple sessions first):
    tmux new -s frontend -d
    tmux new -s backend -d
    tmux new -s database -d
    
  3. Attach to an existing named session:
    tmux attach -t myproject
    
  4. List all sessions (to see names):
    tmux list-sessions
    

    or the shorter:

    tmux ls
    

Inside an Existing tmux Session

If you’re already inside tmux and want to create a new named session:

Renaming an Existing Session

tmux rename-session -t oldname newname

or inside tmux: Ctrl+b then :rename-session newname

Pro Tips

This method works on Linux, macOS, and any system with tmux installed.

References:


Back Donate