# io.github.libtmux.Server.Server

- **Module:** io.github.libtmux.Server
- **Package:** io.github.libtmux:libtmux
- **Language:** Java
- **Kind:** class
- **Source:** https://github.com/libtmux/libtmux-java/blob/c3517519ee799428a809ce6deb1708c8be289cd1/libtmux/src/main/java/io/github/libtmux/Server.java#L33
- **Page:** https://libtmux.org/reference/java/io-github-libtmux-server-server/

One tmux server, reached over one transport.

<p>Ownership is decided at construction and never inferred. {@link #open} creates a transport this
server closes exactly once; {@link #using} borrows one the caller keeps, so several servers can
share a transport and closing one leaves the others working.

<p>Closing a server closes a client, not a tmux. It never kills the server process: sessions
outlive the program that made them, which is the entire point of tmux.

## Members

- `newSession` (method) — Creates a detached session and returns that exact session.
- `hasSession` (method) — Whether a session with this name exists.
- `killSession` (method) — Ends the session with this name, and everything in it.
- `isAlive` (method) — Whether the server is running and answering.
- `raiseIfDead` (method) — Checks the server is answering, and says so loudly when it is not.
- `killServer` (method) — Ends the tmux server and every session on it.
- `batch` (method) — Collects several commands to run in one tmux invocation.
- `chain` (method) — Starts a chain of commands where each one acts on what the last one made.
- `expand` (method) — Expands a tmux format against the server, and answers with what it came to.
- `runShell` (method) — Runs a shell command through tmux, for its effect.
- `runShellCapturing` (method) — Runs a shell command through tmux and answers with what it printed.
- `listCommands` (method) — Every command this tmux knows, as it prints them.
- `ifShell` (method) — Runs one tmux command or another, according to whether a shell command succeeds.
- `lock` (method) — Locks every client attached to this server.
- `messages` (method) — The server's own message log, newest last.
- `promptHistory` (method) — What has been typed at tmux's command prompt, oldest first.
- `clearPromptHistory` (method) — Forgets what has been typed at tmux's command prompt.
- `bindKey` (method) — Binds a key to a tmux command.
- `unbindKey` (method) — Removes a key binding.
- `listKeys` (method) — Every key binding, as tmux prints them.
- `channel` (method) — One of this server's wait-for channels, which is where a signal is sent and waited for.
- `awaitChannel` (method)
- `buffers` (method) — The server's paste buffers, which every session shares.
- `sourceFile` (method) — Runs a file of tmux commands, as a configuration file would be run.
- `options` (method) — The server-wide options, the ones tmux keeps once per server.
- `globalOptions` (method) — The global session options every session inherits unless it sets its own.
- `hooks` (method) — The global hooks every session inherits.
- `version` (method) — Which tmux this server is running.
- `identity` (method) — Which server this is. Every handle taken from it is scoped by this.
- `requireSameServer` (method)
- `requireSameIncarnation` (method)
- `open` (method) — A server over a transport it owns and closes.
- `using` (method) — A server over a transport the caller owns. Closing this server never closes it.
- `builder` (method) — A builder holding the documented defaults.
- `config` (method) — How this server was configured.
- `cmd` (method) — Runs one tmux command against this server.
- `snapshot` (method) — Captures the whole hierarchy in at most four listings, retrying once if the server is replaced.
- `sessions` (method) — Every session, captured now.
- `windows` (method) — Every winlink on the server, captured now, including a linked window once per session.
- `panes` (method) — Every pane on the server, captured now.
- `clients` (method) — Every attached client, captured now.
- `attachedSessions` (method) — Every session a client is attached to, captured now.
- `run` (method) — Runs a command that is expected to work, and raises when it did not.
- `runTogether` (method) — Runs several commands in one invocation, so nothing of this caller's happens between them.
- `refresh` (method)
- `toBuilder` (method) — A builder holding every configuration and ownership choice this server made.
- `close` (method) — Releases an owned transport. Idempotent, and never kills tmux.
- `Builder` (class) — Collects configuration and the ownership choice, then builds a server.
