libtmux Reference MCP Search
On this page

Swift API reference

983 symbols, extracted from source. Every type name in a signature links to its own entry; every cross-reference in a doc comment resolves against the same table.

Server 4 types
Session 2 types
Window 6 types
Pane 4 types
Client 1 type
Hooks 2 types
Options 2 types
Buffers 1 type
Layout and geometry 1 type
Environment 2 types
Versions 1 type
Commands 3 types
Control mode 4 types
Formats 1 type
Queries 6 types
Queries — Operators 2 types
Queries — Expressions 1 type
Snapshots 4 types
Workspaces — Plans 4 types
Errors 11 types
Constants and enums 1 type
MCP 15 types
Testing utilities 2 types
Other 8 types
Functions and constants 0 types
namedSocketRoot : let namedSocketRoot: URL?
constant [source]
constant [source]
namedSocketRoot

The directory a socket *name* resolves inside, when the run provides one.

tmux looks a name up in TMUX_TMPDIR, whose default is shared with every other tmux on the machine — the other libtmux ports' included. A suite that addressed servers by name without moving that directory would put its sockets exactly where anything sweeping by prefix can reach them, which is what this whole root exists to prevent.

So the directory is taken from the environment rather than set into it. The obvious alternative — setenv from the fixture — writes to environ while other cases are concurrently reading it to build a tmux environment, and that is a data race whether or not it has bitten yet. Cases that address a socket by path do not care either way, -S being absolute.

CONTRIBUTING.md and CI name the directory; namedSocketsAvailable is what the suite checks so a run without one skips those cases rather than scattering sockets.

namedSocketsAvailable : var namedSocketsAvailable: Bool
constant [source]
constant [source]
namedSocketsAvailable

Whether this run can address servers by socket name inside the suite's root.

reaperCommand(root:) ( root : URL ) TmuxCommand
function [source]
function [source]
reaperCommand(root:)

A reaper that outlives this process, so a killed run leaves no server behind.

Arm it in the same invocation that creates the server's first session, and give it the directory holding the socket. Public because the benchmark provisions its own servers — with a counting shim standing in for tmux — and a second copy of this reasoning is a second copy to get wrong.

defer and kill-server both run *in the process that started the server*, which makes them useless in the one case that actually leaks: the run is killed outright by a harness timeout or an impatient operator, and every tmux server it started survives with no owner and no way to reach it. Cleanup that depends on the cleaner surviving is not deterministic.

So the reaper lives inside the tmux server instead, as a background job. It watches the owning process and, once that is gone, removes the directory and kills the server. Three details carry the design:

  • The directory goes first. kill ends the server, and tmux kills its jobs when it exits, so anything sequenced after it would not run.
  • The server is addressed by pid, not by socket, because the socket is inside the directory just removed.
  • #{pid} is left for tmux to expand rather than asked for first, which is what lets arming ride in the same invocation that creates the session. Sent separately, a run killed in the gap between the two leaves a server no reaper ever covered — measurably, under load, about one server in six.
  • The interval is whole seconds. Fractions are a GNU and BSD extension that POSIX does not require, and a sleep that rejects its argument turns this into a busy loop per server rather than a slower one. Reaping a second later costs nothing here.
tmuxExecutablePath() ( ) String
function [source]
function [source]
tmuxExecutablePath()

The lane binary when a matrix runner selected one, otherwise whatever tmux resolves to. Resolved to a path because the transport never searches PATH.

waitForShellPrompt(on:within:) ( on : Server , within : Duration ) ()
functionasync [source]
functionasync [source]
waitForShellPrompt(on:within:)

Waits until a pane's shell has drawn its first prompt.

Keys sent before that are echoed with no prompt in front of them, which leaves the prompt to land on the row the command's own output wants. A case looking for a row equal to what it printed is then waiting for something that cannot arrive, and reports it as a timeout naming nothing. One capture settles it for every case that follows.

What the prompt *says* is not portable — sh is dash on Linux and bash on macOS, which prints sh-3.2$ — so readiness is that the pane has drawn anything at all. Until the shell starts it has drawn nothing.

This reads the pane directly rather than through the wait machinery: a fixture that bootstrapped itself with the code under test would make every unrelated case depend on it.

waitUntil(within:_:) ( within : Duration , condition : () async throws -> Bool ) Bool
functionasync [source]
functionasync [source]
waitUntil(within:_:)

Polls condition until it holds, and reports whether it did.

Bounded in wall-clock rather than in attempts. What makes one of these polls slow is the tmux call inside it, so a count of attempts says nothing about how long the loop can run: on a contended machine a generous-looking budget outlives the case's time limit, and the failure reads as a timeout instead of naming the thing that never became true.

Raises
withNamedTmuxServer(_:) ( body : (Server) async throws -> Result ) Result
functionasync [source]
functionasync [source]
withNamedTmuxServer(_:)

Runs body against a private tmux server addressed by socket *name*, and always kills it.

The same guarantees as withTmuxServer(_:) — its own server, killed on the way out and reaped if this process is killed outright — for the half of Endpoint that a path-addressed fixture never exercises.

Raises
withTmuxServer(socketFileName:_:) ( socketFileName : String , body : (Server) async throws -> Result ) Result
functionasync [source]
functionasync [source]
withTmuxServer(socketFileName:_:)

Runs body against a private tmux server and always kills it — including when this process is killed outright.

Each case gets its own socket, so cases never see each other's sessions and teardown never touches a server it did not start. The server is bootstrapped with one session named bootstrap: a tmux server exits as soon as its last session goes away, so without one there is nothing to hold it open. Scope assertions to the objects the case created rather than to the server being otherwise empty.

Raises
exactlyOne(_:) ( expression : FilterExpr<Element> ) Self.Element
method [source]
method [source]
exactlyOne(_:)

The one element the filter matches.

Distinguishes "nothing matched" from "several matched", because a caller that meant to address one object needs to know which mistake it made.

filter(_:) ( expression : FilterExpr<Element> ) [Self.Element]
method [source]
method [source]
filter(_:)

Every element the filter matches, in order.

Returns a plain array: ordered, replayable, and free of any live connection to tmux.

oneOrNil(_:) ( expression : FilterExpr<Element> ) Self.Element?
method [source]
method [source]
oneOrNil(_:)

The one element the filter matches, or nil if none did.

Only ambiguity is an error here; absence is an ordinary answer.

SubscriptionChangeStream : typealias SubscriptionChangeStream
typealias [source]
typealias [source]
SubscriptionChangeStream

A lazy view of subscription changes from one bounded notification observer.

Esc

Type to search.