Skip to main content
Back to Commands
Session ManagementN/A (run from shell)

attach-session

Short form: attach, a

Attach to an existing session. If no session is specified, attach to the most recently used session. If no sessions exist, an error is reported.

Synopsis

bash
tmux attach-session [-dErx] [-c working-directory] [-f flags] [-t target-session]

Options

FlagDescription
-dDetach any other clients attached to the session
-rAttach in read-only mode
-t target-sessionSpecify which session to attach to
-c working-directorySet the working directory for the attached client

Examples

Attach to most recent session

bash
tmux attach

Short form - attach to most recent session

bash
tmux a

Attach to session named 'dev'

bash
tmux attach -t dev

Attach to session number 0

bash
tmux a -t 0

Attach and detach all other clients

bash
tmux attach -d -t main

Attach in read-only mode (observer)

bash
tmux attach -r -t shared

Default Keybinding

N/A (run from shell)

Default prefix is Ctrl+b

Pro Tips

  • Use 'tmux a' as a quick shorthand for attaching
  • The -d flag is useful for taking over a session from another machine
  • Read-only mode (-r) is perfect for pair programming or demos