# tmux.Session.Attach

- **Module:** tmux.Session
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/server_attach.go#L99
- **Page:** https://libtmux.org/en/go/latest/reference/tmux-session-attach/

```
tmux.Session.Attach(ctx: context.Context, options: AttachSessionOptions) -> error
```

Attach attaches the caller's terminal to this session's stable identifier and blocks until detach or context cancellation. It validates the receiver's stable SessionID, retains but never closes caller-supplied streams, and returns [CommandError] for a completed nonzero exit. Cancellation does not prove attachment or detachment did not occur. It leaves tmux's own locale detection alone for the reason [Server.AttachSession] gives.
