# 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/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/server_attach.go#L94
- **Page:** https://libtmux.org/reference/go/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.
