# session.Session

- **Module:** session
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** class
- **Source:** https://github.com/libtmux/libtmux-ts/blob/3fe1ca654b81b8cbf4a13b777a001a3298c87a6f/packages/libtmux/src/session.ts#L51
- **Page:** https://libtmux.org/en/ts/latest/reference/session-session/

One session on one tmux server, as a handle rather than a copy of it.

Reached from {@link Server.sessions} or by creating one; the constructor
throws. The tmux format row the handle was built from reads back through
`format`, and by tmux's own field names directly on the handle — a snapshot
taken when the handle was made, not a live view.

A session outlives the clients attached to it: killing the last client
leaves the session running, which is the property the whole tool is built
around.

## Members

- `sessionBrand` (attribute)
- `server` (attribute): The server this handle addresses.
- `constructor` (method)
- `windows` (method): Windows placed in this session, in listing order.
- `panes` (method): Panes contained by this session's windows.
- `showOptions` (method): Every option set on this session itself, not the ones it inherits.
- `showResolvedOptions` (method): The option values that govern this session, own and inherited together.
- `setOption` (method): Set an option on this session.
- `unsetOption` (method): Remove an option from this session.
- `showHooks` (method): Every hook this session reports.
- `setHook` (method): Bind a tmux command to a hook on this session.
- `unsetHook` (method): Remove a hook from this session.
- `showEnvironment` (method): Every variable in this session's environment.
- `getEnvironment` (method): One variable from this session's environment, or `undefined` when tmux carries no entry.
- `setEnvironment` (method): Set a variable in this session's environment.
- `unsetEnvironment` (method): Drop a variable from this session's environment entirely.
- `removeEnvironment` (method): Mark a variable in this session's environment for removal from the environment of processes tmux starts, leaving the entry in place.
- `activeWindow` (method): The window tmux marks active in this session.
- `activePane` (method): The pane tmux marks active in this session's active window.
- `newWindow` (method): Create a window in this session and resolve it as a handle.
- `plan` (method): The same mutations, described instead of run.
- `kill` (method): Destroy this session.
- `refreshed` (method): This session, read again at a new instant.
- `rename` (method): Rename this session.
- `selectWindow` (method): Select the last, next, or previous window, or one named by target.
- `fromEnv` (method): Resolve the session this process is running inside.
- `detach` (method): Detach every client attached to this session.
- `cmd` (method): Run a tmux command this package does not model, addressed at this session.
- `equals` (method): Whether `other` is this same session on this same server.
- `sameTmuxIdAs` (method): Whether `other` carries the same `$n`, wherever it came from.
- `toString` (method): How this handle renders in a log line, a template literal, or an error.
- `format` (property): The raw tmux format row, addressed by tmux's own token names.
