# tmux.Session.Rename

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

```
tmux.Session.Rename(ctx: context.Context, name: string) -> (Session, error)
```

Rename changes the receiver session's name and returns a canonical freshly materialized [Session]. If the command succeeds but refresh fails, it returns the receiver with that error. A transport or context error can be delivery-ambiguous; no rollback is attempted. Invalid names are rejected before execution and match [ErrInvalidRequest].
