# Server

- **Package:** libtmux-swift
- **Language:** Swift
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-swift/blob/f02a4668570e1cc5198c941413750e021f42c214/Sources/LibTmux/Server.swift#L9
- **Page:** https://libtmux.org/reference/swift/server/

A tmux server, addressed by its endpoint.

`Server` is a value: copying one is free, copies compare equal, and passing
one across a task boundary needs no ceremony. The mutable part — the process
boundary and anything cached about the running daemon — lives behind an
actor that every copy shares, so two copies of the same server coordinate
with each other rather than racing.

## Members

- `buffers()` (method) — The server's paste buffers, most recent first.
- `setBuffer(_:named:)` (method) — Puts text into a named buffer.
- `buffer(named:)` (method) — Reads a buffer's contents, or `nil` if no such buffer exists.
- `deleteBuffer(named:)` (method)
- `loadBuffer(from:named:)` (method) — Fills a buffer from a file, letting tmux read it.
- `saveBuffer(named:to:)` (method) — Writes a buffer to a file, letting tmux do the writing.
- `paste(buffer:into:)` (method) — Pastes a buffer into a pane.
- `capture(_:since:limit:)` (method) — Reads only what a pane has printed since `cursor`.
- `run(_:)` (method) — Runs a list of commands in one tmux invocation.
- `connected(attachingTo:_:)` (method) — Runs `body` with every command carried by one live connection instead of a new tmux process each time.
- `using(_:_:)` (method) — Runs `body` with this server in `mode`.
- `withControlMode(attachingTo:_:)` (method) — Opens a control-mode connection for the duration of `body`, handing over the connection itself.
- `newSession(named:startDirectory:windowName:)` (method) — Creates a detached session.
- `newWindow(in:named:startDirectory:)` (method) — Creates a window in a session and returns its exact appearance.
- `newWindow(_:_:named:startDirectory:)` (method) — Creates a window next to one that already exists and returns its exact appearance.
- `splitWindow(_:direction:size:startDirectory:)` (method) — Splits a window's active pane, returning the pane that appeared.
- `split(_:direction:size:startDirectory:)` (method) — Splits one pane, returning the pane that appeared.
- `environment(_:)` (method) — Every variable in an environment, in the order tmux printed them.
- `environmentValue(_:in:)` (method) — What one variable is set to, or `nil` when it is unset or marked for removal.
- `setEnvironment(_:to:in:)` (method) — Sets a variable, replacing whatever was there.
- `unsetEnvironment(_:in:)` (method) — Unsets a variable, leaving no trace of it.
- `removeEnvironment(_:in:)` (method) — Marks a variable so new processes start without it, even when it is set in the environment tmux itself was started from.
- `format(_:for:)` (method) — Evaluates a tmux format and hands back what it printed.
- `format(_:for:through:)` (method) — Evaluates a tmux format against a pane through one of its window links. See ``format(_:for:)-(String,Session)``.
- `format(_:addressing:)` (method) — Evaluates a tmux format against a target named by id.
- `format(_:)` (method) — Evaluates a tmux format against the server rather than any one object.
- `rename(_:to:)` (method)
- `selectLayout(_:_:)` (method) — Applies one of tmux's own layouts — `even-horizontal`, `tiled`, and the rest — to a window.
- `resize(_:width:height:)` (method) — Sets a pane's size outright.
- `resize(_:by:toward:)` (method) — Nudges a pane's boundary, leaving the rest of the layout to absorb it.
- `kill(_:)` (method)
- `select(_:)` (method)
- `selectNextWindow(in:)` (method) — Moves to the next window of a session, wrapping at the end.
- `selectPreviousWindow(in:)` (method)
- `selectLastWindow(in:)` (method) — Returns to the window that was active before the current one.
- `selectLastPane(in:)` (method) — Returns to the pane that was active before the current one.
- `swap(_:with:)` (method) — Swaps two window appearances. Their underlying window ids do not change, but both links move to new indices.
- `rotate(_:upward:)` (method) — Shifts every pane in a window one position around the layout.
- `nextLayout(_:)` (method) — Cycles a window through tmux's preset layouts.
- `previousLayout(_:)` (method)
- `breakPane(_:from:named:)` (method) — Moves a pane out into a window of its own, and returns its appearance.
- `join(_:into:direction:size:)` (method) — Moves a pane into another window, splitting it.
- `clearHistory(_:)` (method) — Clears a pane's visible screen and its scrollback.
- `setTitle(_:of:)` (method) — Sets a pane's title. The title is only shown when tmux is configured to display it, but it is always readable through a format.
- `detach(_:)` (method) — Detaches a client from the server it is attached to.
- `detachClients(from:)` (method) — Detaches every client attached to a session.
- `startServer()` (method) — Starts the server if it is not already running.
- `killServer()` (method)
- `sourceFile(_:)` (method) — Loads a tmux configuration file into the running server.
- `requireRunning()` (method) — Throws unless a server is listening.
- `respawn(_:running:killingExisting:)` (method) — Restarts the command in a pane.
- `pipe(_:to:)` (method) — Copies everything a pane outputs to a shell command, or stops doing so when `command` is omitted.
- `options(_:)` (method) — Every option set in one exact table.
- `option(_:scope:)` (method) — The value of one option, or `nil` if it is not set in that table.
- `setOption(_:to:scope:)` (method) — Sets an option.
- `unsetOption(_:scope:)` (method) — Puts an option back the way it was before anyone set it.
- `hooks(_:)` (method) — Hooks tmux has a command for.
- `setHook(_:to:at:in:)` (method) — Binds a command to a hook.
- `unsetHook(_:in:)` (method) — Unbinds every command from a hook.
- `runHook(_:in:)` (method) — Runs a hook's commands now, without waiting for what would trigger it.
- `sendKeys(_:to:literally:)` (method) — Sends keys to a pane.
- `run(_:in:)` (method) — Runs a shell command line in a pane, as if typed.
- `shellInvocation` (property) — How a command running *inside* a pane spells a tmux that reaches this server.
- `capture(_:includingHistory:)` (method) — The pane's visible contents, one line per row. The source read is capped at 1 MiB; use incremental capture for a large scrollback instead of collecting its entire history.
- `capture(_:includingHistory:maximumLines:)` (method) — Reads the newest rows without collecting older rows that will be discarded.
- `!=(_:_:)` (function) — Returns a Boolean value indicating whether two values are not equal.
- `endpoint` (property) — Where this server listens. Every command carries it, so no call can reach the ambient server by accident.
- `tmuxExecutable` (property) — The tmux this server runs, resolved to a path.
- `mode` (property) — How work from this server reaches tmux.
- `init(socketPath:tmuxExecutable:)` (method)
- `init(socketName:tmuxExecutable:)` (method)
- `sessions()` (method) — Every session on this server, in tmux's own order.
- `windows()` (method) — Every window on this server, in tmux's own order.
- `windowLinks()` (method) — Every session-local link to a window, in tmux's own order.
- `panes()` (method) — Every pane on this server, in tmux's own order. A pane whose window has several session links appears once.
- `clients()` (method) — Every client attached to this server.
- `snapshot()` (method) — Reads every object from one daemon incarnation.
- `serverProcessID()` (method) — The running server's process id.
- `incarnation()` (method) — The running daemon at this endpoint.
- `hasSession(_:)` (method) — Whether a session by this name or id exists.
- `isRunning()` (method) — Whether a server is listening on this endpoint.
- `==(_:_:)` (function) — Returns a Boolean value indicating whether two values are equal.
- `hash(into:)` (method) — Hashes the essential components of this value by feeding them into the given hasher.
- `version()` (method) — Which tmux this server runs.
- `wait(for:)` (method) — Blocks until something signals `channel`.
- `signal(_:)` (method) — Releases one waiter on `channel`.
- `waitForOutput(in:matching:stoppingAt:requiringFreshOutput:timeout:tailLimit:)` (method) — Waits until a pane prints something, driven by tmux output events.
- `move(_:to:)` (method) — Moves one window appearance into another session.
- `link(_:into:)` (method) — Links a window into another session. The same window then appears in both, sharing one id — which is tmux's model, not a copy. The source is global because no existing session-local appearance is involved.
- `unlink(_:)` (method) — Removes one of a linked window's appearances. The window survives while any session still holds it.
