# server.Server

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

One tmux server, addressed by the socket it listens on.

Constructing this starts no process. tmux spawns the daemon on the first
command that needs one, and a daemon already listening on that socket is
used rather than replaced, so two `Server` values built from the same
options address the same tmux.

Sessions, windows and panes are reached from here and carry the server with
them. Handles taken from one daemon do not survive its restart: the
replacement numbers panes from `%0` again — see {@link DaemonIdentity}.

## Members

- `serverBrand` (attribute)
- `constructor` (method)
- `withConnection` (method): Run `body` against a connected server, closing it afterwards.
- `colors` (method): How many colours this server was told the terminal has.
- `configFile` (method): The configuration file this server was pointed at, if any.
- `socketName` (method): The socket name this server addresses, if it was named rather than pathed.
- `socketPath` (method): The socket path this server addresses, if it was given one.
- `tmuxBin` (method): The tmux executable this server runs.
- `toString` (method): How this server renders in a log line or an error.
- `watch` (method): Stream tmux's control-mode notifications until the stream is disposed.
- `connect` (method): Bind this server to one control-mode connection and return it.
- `snapshot` (method): Acquire an immutable view of the server at this instant.
- `sessions` (method): Every session on the server, read now.
- `windows` (method): Every window on the server, including each placement of a linked window.
- `panes` (method): Every pane on the server.
- `daemonIdentity` (method): Which daemon is answering on this socket right now.
- `clients` (method): Every client attached to the server.
- `showOptions` (method): Every server-scope option tmux currently reports.
- `showResolvedOptions` (method): The option values that govern this server, own and inherited together.
- `setOption` (method): Set a server-scope option.
- `unsetOption` (method): Remove a server-scope option.
- `saveBuffer` (method): Write a paste buffer to a file instead of reading it back.
- `showGlobalOptions` (method): Read the defaults every session or window inherits.
- `setGlobalOption` (method): Set a default every session or window inherits.
- `unsetGlobalOption` (method): Remove a default, so tmux falls back to its own built-in value.
- `showHooks` (method): Every global hook tmux currently reports.
- `setHook` (method): Bind a tmux command to a global hook.
- `unsetHook` (method): Remove a global hook.
- `version` (method): The tmux version this server is running.
- `versionAtLeast` (method): Whether this server is at least `minimum`, written the way tmux writes it.
- `showEnvironment` (method): Every variable in the server's global environment.
- `getEnvironment` (method): One variable from the server's global environment, or `undefined` when tmux carries no entry.
- `setEnvironment` (method): Set a variable in the server's global environment.
- `unsetEnvironment` (method): Drop a variable from the server's global environment entirely.
- `removeEnvironment` (method): Mark a variable in the server's global environment for removal from the environment of processes tmux starts, leaving the entry in place.
- `newSession` (method): Create a detached session and resolve it as a handle.
- `kill` (method): Terminate the tmux server and every session on it.
- `hasSession` (method): Whether a session with this name exists.
- `sourceFile` (method): Run a tmux config file against this server.
- `listCommands` (method): Every command name the running tmux understands.
- `loadBuffer` (method): Fill a paste buffer from data fed through tmux's stdin.
- `setBuffer` (method): Put a string into a named paste buffer.
- `showBuffer` (method): Read a named paste buffer's contents.
- `showBufferBytes` (method): Read a named paste buffer without decoding or splitting its bytes.
- `listBuffers` (method): Every buffer name this server holds.
- `deleteBuffer` (method): Discard a named paste buffer.
- `runShell` (method): Run a shell command through tmux and return whatever it printed.
- `ifShell` (method): Run one command or another depending on a condition.
- `isAlive` (method): Whether the tmux server is reachable.
- `checkAlive` (method): Assert the server is reachable, raising with tmux's reason if not.
- `raiseIfDead` (method): Assert the server is reachable, raising with tmux's reason if not.
- `cmd` (method): Run a tmux command this package does not model.
- `pipeline` (method): Run several tmux commands in order.
- `batch` (method): Run planned mutations in order, resolving each to what it made.
- `equals` (method): Whether `other` is a handle addressing the same tmux server.
