# libtmux for Elixir > The Elixir library (libtmux). These pages include its guides, tested examples and API documentation. - [Elixir API reference](https://libtmux.org/en/elixir/pr-173/reference/): every public symbol, generated from the source. Hosted on libtmux.org. --- # Concepts Source: https://libtmux.org/en/elixir/pr-173/concepts/ > Understand captured queries, object identities, and operations. Understand captured queries, object identities, and operations. - [Read values, execute explicitly](https://libtmux.org/en/elixir/pr-173/concepts/mental-model/): Hold one captured graph for several decisions and run a command when you need another. - [Captured tmux state](https://libtmux.org/en/elixir/pr-173/concepts/observations/): Capture an immutable snapshot of an existing server and read it without further commands. --- # Read values, execute explicitly Source: https://libtmux.org/en/elixir/pr-173/concepts/mental-model/ > Hold one captured graph for several decisions and run a command when you need another. - Capture once when several decisions need the same graph, and keep that snapshot while you select and filter. - Run a new command explicitly for another observation or an effect. - Capture covers an interval, so fields can change during it. The value you get stays fixed while tmux keeps changing. ## The values you hold | Value | What it represents | I/O boundary | | --- | --- | --- | | [`LibTmux.Server`]() | Executable, socket choice and environment for an existing server | Pure descriptor construction | | [`LibTmux.Snapshot`]() | An indexed graph captured over one interval | [`LibTmux.Server.snapshot/2`]() captures a new value | | [`LibTmux.Selection`]() | Ordered items and their originating snapshot | Filtering and enumeration use captured values | | [`LibTmux.Ref`]() | An observed exact ID and server instance | Pure identity data; it reserves nothing | | [`LibTmux.Control`]() | A handle pinned to one connection epoch | Status reads are local; startup explicitly attaches a client | | [`LibTmux.Operation`]() | Access to one retained operation record | Result/status reads are local; awaiting registers a separate waiter | - Windows are physical objects. [`LibTmux.WindowLink`]() gives a window's session membership, index and active state. - A linked window can appear more than once, while its panes stay the same physical panes. - Choose window links when membership matters. Choose panes when an action should address each physical pane once. See [captured state](https://libtmux.org/en/elixir/pr-173/concepts/observations/). ## Coverage tells you which questions the graph can answer - A loaded field holds a value, an empty string or a documented [`nil`](). - `:unloaded` means this snapshot lacks the observation. `:unavailable` means the capability is absent. Neither means known absence. - Relationship predicates need complete captured join domains. A missing pane relation cannot satisfy "no pane matches." - Validation raises a structured coverage error before filtering, even for an empty selection. - Capture again explicitly for more coverage. Existing selections keep their graph. See [filtering](https://libtmux.org/en/elixir/pr-173/guides/filtering/). ## Server identity and connection epochs have different lifetimes - A server instance identifies one tmux process incarnation. Native object IDs can be reused after that process exits. - References keep the observed instance, so qualified control requests can reject known stale targets. One-shot commands keep a check/use race; an observed ID reserves nothing. - An epoch identifies one control connection and its owned transport actors. The server instance can stay the same while the epoch changes. - [`LibTmux.Control.reconnect/2`]() returns the ready epoch, unchanged if it is already ready. Close first to require a replacement. - A replacement waits for retirement and returns a new pinned handle. Old handles cannot submit into it, and reconnect never replays work. ## Waiting, command outcomes and retirement are separate | Result | What the caller can conclude | | --- | --- | | [`LibTmux.Control.submit/3`]() returns `{:ok, operation}` | Admission succeeded; inspect or await the retained operation | | [`LibTmux.Operation.await/2`]() returns an API timeout | This waiter ended; the operation may still advance | | A canonical outcome is `:completed` or `:failed` with `:acknowledged` certainty | tmux supplied a command reply; arbitrary programs started by that command have their own lifetimes | | A canonical outcome is `:skipped` with `:no_write` certainty | The operation was classified before dispatch | | A canonical outcome is `:unknown` | Available evidence cannot determine its effects | | Operation status reports `wire: :retired` | Reply attribution has retired; the retained record may still occupy capacity | | [`LibTmux.Control.close/2`]() returns `:ok` | The pinned connection epoch retired; its enclosing supervisor remains running | - Each await call has its own budget. A timeout or the caller's death ends that waiter without cancelling the operation. - For wire-active work, [`LibTmux.Operation.stop/1`]() asks to close the whole pinned epoch and can affect siblings. An already retired operation returns `:ok` without closing its connection. - [`LibTmux.Control.close/2`]() waits for connection retirement. - Inspect retained results instead of replaying an uncertain mutation. - A canonical outcome never changes once it exists. Bang operation APIs raise API and context errors, and still return failed, skipped and unknown outcomes as values. - Wire retirement, record expiry and native process cleanup each have their own evidence. [Ownership](https://libtmux.org/en/elixir/pr-173/topics/ownership/) covers deadlines, bounds and remaining limits. ## Return conventions These APIs answer different questions. Command completion does not mean that a program started by tmux has finished. | API | Normal return | Failure handling | | --- | --- | --- | | Domain actions such as [`LibTmux.Window.rename/4`]() | `{:ok, result}` only for completion, retaining value and evidence | Unsuccessful outcomes use [`LibTmux.Action.CompletionError`](); API and admitted execution errors retain their own types | | Domain bangs such as [`LibTmux.Window.rename!/4`]() | Completed value | Raise the same errors with their evidence | | [`LibTmux.Control.execute/3`]() and [`LibTmux.Operation.await/2`]() | `{:ok, canonical_result}`, including failed, skipped and unknown outcomes | Outer errors describe execution context or waiting; their bangs raise those errors and return canonical outcomes unchanged | | [`LibTmux.Selection.one/2`]() and [`LibTmux.Selection.one_or_nil/2`]() | `{:ok, item}`, or allowed `{:ok, nil}` | Cardinality errors are tuples; bangs raise them. Predicate and coverage validation can raise in either form | | Relationship helpers such as [`LibTmux.Session.panes/2`]() | Ordered selection, or observation/nil for to-one relationships; no I/O | Identity, coverage and ambiguity errors raise | | [`LibTmux.Control.with_connection/2`]() | `{:ok, callback_value}` after cleanup, even when that value is `{:error, reason}` | Startup errors return errors; callback raise/throw/exit propagates after cleanup. Unproved cleanup returns [`LibTmux.Control.ScopeFailure`]() preserving the primary outcome | - The [recovery example](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/recovery.md) handles lower-level execution and cleanup separately. - Option validation may raise. A name without a bang does not promise that every malformed call returns an error tuple. --- # Captured tmux state Source: https://libtmux.org/en/elixir/pr-173/concepts/observations/ > Capture an immutable snapshot of an existing server and read it without further commands. - [`LibTmux.Server.new/1`]() builds a descriptor with an explicit executable and a socket choice. The choice is a path, a name, one of `LIBTMUX_SOCKET_PATH` and `LIBTMUX_SOCKET`, or none, which leaves it to tmux. It does no I/O. - [`LibTmux.Server.snapshot/2`]() observes that existing server and returns an immutable [`LibTmux.Snapshot`](). - Neither call attaches a control client or starts a missing server. - Configured tmux hooks remain environmental effects of commands, including list commands. ## Read one captured graph - [`Snapshot.items/2`]() returns a plain list for an entity atom or module. - [`Snapshot.fetch/3`]() looks up an exact ID. - [`Snapshot.related/4`]() follows captured indexes, and raises a structured coverage error when a relation is incomplete. - [`Snapshot.sessions/1`](), `windows/1`, `panes/1`, `window_links/1` and `clients/1` return materialized selections. - None of these does I/O. See [filtering](https://libtmux.org/en/elixir/pr-173/guides/filtering/) for local predicates and portable criteria. For common relationships, pass the snapshot and a session or window observation to [`Session.windows/2`](), [`Session.panes/2`](), [`Session.active_window/2`]() or [`Window.panes/2`](): - The plural helpers return selections for filtering and checked cardinality with [`LibTmux.Selection`](). `active_window/2` returns a window or [`nil`](). - They validate the observation's kind, ID and server incarnation, then use the supplied graph's fields and coverage. An older observation from the same incarnation is valid, and its other fields are ignored. - Each selection keeps the supplied graph. `Enum.to_list/1` gives a plain list without it. - Direct traversal validates only the requested source. One session's active window does not fail because another session has ambiguous active links. - Relationship filters validate their whole captured source domain before iteration, even when the selection is empty. Sessions, physical windows, panes and clients have separate maps: - A pane belongs to one physical window. - [`WindowLink`]() records session membership, window index and active state. Its key is session ID, index and window ID, which does not prove a unique lifetime after unlink and relink. - A window can appear at several indexes in one session, and in other sessions. Server-wide physical maps deduplicate identical rows and reject conflicting rows. - Session pane traversal returns each physical pane once. Window-link traversal keeps memberships. - Sessions, windows and panes sort by numeric native ID. A session's windows follow their first link's index; its panes sort by numeric pane ID. Links sort by numeric session ID and index. Clients sort bytewise by observed name. Field notes: - [`Session.attached_count`]() keeps tmux's raw client count, and [`attached`]() is derived from it. Control clients stay counted even with `no-output` and `ignore-size`. - A control client's height is known [`nil`]() when tmux reports no started tty. It is not an unavailable field. - [`Pane.pid`]() is known [`nil`]() when tmux reports no PID, including empty and retained dead panes on tmux 3.8. Other values stay as reported: older tmux can report zero for an empty pane, or a historical PID for a dead one. Neither a PID nor its absence proves a process is alive or cleaned up. ## Compare two snapshots This example links one physical window into a second session at indexes 7 and 8. It captures the graph, unlinks index 7, then captures again. Compare [`WindowLink.id`]() values to find added and removed memberships. Each key contains the session ID, index and physical window ID, so replacing the window at an index gives a removal and an addition. Require complete window link coverage in both captures and check that they came from the same server incarnation before comparing their IDs. ```elixir unless before.server_instance == later.server_instance do raise "the captures describe different tmux servers" end link_ids = fn snapshot -> :ok = Snapshot.require_complete!(snapshot, :window_link) Enum.map(Snapshot.window_links(snapshot), & &1.id) end before_ids = link_ids.(before) later_ids = link_ids.(later) removed = before_ids -- later_ids added = later_ids -- before_ids ``` From this checkout, with tmux on `PATH`: ```console $ mix run examples/snapshot_changes.exs ``` It prints: ```text {"removed":[["$1",7,"@0"]],"added":[],"window":"@0","panes":["%0","%2"],"destination_indexes":[8],"held_destination_indexes":[7,8],"same_panes":true} ``` Only the membership at index 7 disappeared. Index 8 still points to the same window with both original panes. The held snapshot still has both memberships. The comparison reports differences between captured keys. Changes to fields such as the active flag, and an unlink and relink of the same key between captures, are outside that comparison. ## Coverage and construction - [`Snapshot.new/2`]() validates fixture or adapter observations without I/O. - [`fields`]() declares loaded fields over the supplied entity IDs. `complete` declares complete server entity sets; omissions stay partial. `unavailable` declares absent capabilities separately. - Declared names and values validate before indexes or relations become observable. - Known empty strings, known nullable values, `:unloaded` and `:unavailable` stay distinct. Required coverage checks run even for empty entity sets. - Derived attachment coverage follows its source count. - A relation to many objects needs a complete join domain, so missing children never become an empty relation. Complete target sets reject dangling references. A partial target set can keep unresolved foreign IDs, but traversal fails explicitly. The [generated schema](https://libtmux.org/en/elixir/pr-173/topics/schema/) owns field types, wire names, tmux variables and relation cardinalities. Physical windows carry no single session, session index or active membership flag. ## Capture consistency and bounds - Capture reads topology, then named fields, then topology again. It checks the tmux PID against Linux boot identity and process start ticks before and after those reads. - Two empty session listings from the same server incarnation yield a complete graph with all entity sets empty. These reads use the same capture budgets. - A replaced server or changing references trigger finite read retries, as does a disappearing read target. Invalid encoding and other decoding errors stay visible. - Two attempts are the default; request one to three. All attempts share one deadline and the original budgets. - Defaults: 1024 contextual topology rows, 512 commands, 8 MiB total response bytes, 64 KiB per response and 5000 ms. - Stdout and stderr both consume the byte budget, including failed-command output. Overload returns an error, not a truncated success. - Topology checks and retries also consume work. An overflowing pane listing can fall back to smaller listings or individual reads. That work stays charged to the original budgets. See [capture rows](https://libtmux.org/en/elixir/pr-173/topics/encoding/#capture-rows). - One-shot retirement has a separate allowance; see [ownership](https://libtmux.org/en/elixir/pr-173/topics/ownership/). Encoding: - Free-form fields use the qualified versioned encoder. Numeric and ID topology columns validate their whole representation. - Client rows combine one encoded identity with restricted scalar columns, so tabs and newlines cannot escape the identity. - This is a fixed capture schema, not a general raw-format row parser. A capture records an observation, not a transaction: - Attributes can change within the interval. Matching topology before and after does not prove nothing changed in between. - Holding a snapshot reserves no objects. - Its server instance differs from a future connection epoch, and one-shot checks keep a check/use race. - Sending a snapshot between BEAM processes can copy terms, and keeping one keeps its graph. ## Diagnose capture work [`LibTmux.Server.snapshot_with_diagnostics/2`]() puts a work report in the third tuple element on success or error. Compare two response ceilings against the same graph: ```elixir {:ok, narrow, narrow_report} = Server.snapshot_with_diagnostics(server, max_response_bytes: 2500) {:ok, wide, wide_report} = Server.snapshot_with_diagnostics(server, max_response_bytes: 8192) ``` The runnable example creates a private server with four panes and checks that both captures return the same long titles. ```console $ mix run examples/capture_diagnostics.exs ``` | Capture | Commands | Pane batch reads | Individual reads | | --- | ---: | ---: | ---: | | 2500 bytes per response | 15 | 2 | 0 | | 8192 bytes per response | 13 | 0 | 0 | At 2500 bytes the full pane listing overflows. The fallback record names `:pane` and counts two batch reads, one per ID range. The byte count includes the retained prefix of the overflowing response. The last call sets a command limit to stop before either batch and returns a capture error with the report. Use `max_response_bytes` to fit a known large row or listing. `max_bytes` and [`timeout`]() still bound the entire capture, including every fallback. Log the report alone to leave out captured output that may be present in the error. --- # tmux client library for Elixir Source: https://libtmux.org/en/elixir/pr-173/core/ > tmux client library for Elixir. Control tmux, navigate sessions, windows, and panes, watch for changes via control mode Control tmux, navigate sessions, windows, and panes, watch for changes via control mode. ## At a glance | Type | Wraps | | ---- | ----- | | [`LibTmux.Server`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-server/) | A tmux server | | [`LibTmux.Session`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-session/) | A session, ID `$n` | | [`LibTmux.Window`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-window/) | A window in a session, ID `@n` | | [`LibTmux.Pane`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-pane/) | A pane in a window, ID `%n` | ## Typed API - Typed objects instead of parsed format strings: [`LibTmux.Pane`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-pane/) - Filtering and queries over tmux objects: [`LibTmux.Filter`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-filter/) - Typed errors instead of exit codes and stderr: [`LibTmux.Error`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-error/) ## What you get over the tmux CLI - Traversal from a server down to its panes: [`LibTmux.Snapshot.panes/1`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-snapshot-panes-1/) - Watch for changes through tmux control mode: [`LibTmux.Control`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-control/) - Arguments passed as a list, with no shell quoting: [`LibTmux.Command`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-command/) - [Guides](https://libtmux.org/en/elixir/pr-173/guides/): Task guides for Elixir. - [Topics](https://libtmux.org/en/elixir/pr-173/topics/): Subject-by-subject, with Elixir in every code block. - [Examples](https://libtmux.org/en/elixir/pr-173/examples/): Complete programs, sourced from the code each port tests. - [API reference](https://libtmux.org/en/elixir/pr-173/reference/): Types and functions of the Elixir API. --- # API glossary Source: https://libtmux.org/en/elixir/pr-173/reference/glossary/ > Kinds, modifiers and package labels in the Elixir API reference. ## Symbol kinds Kinds identify declarations in the Elixir API reference. ### module An Elixir module, a named collection of functions, macros and types defined with defmodule. Module names are atoms, and a nested name such as LibTmux.Control.Request is one flat module rather than a child of LibTmux.Control. References: [Elixir modules and functions](https://elixir.hexdocs.pm/modules-and-functions.html). ### interface An Elixir behaviour, a module that declares callbacks other modules implement. A module implements a behaviour with the @behaviour attribute and defines each required callback. References: [Elixir behaviours](https://elixir.hexdocs.pm/typespecs.html#behaviours). ### struct An Elixir module that defines a struct: a map with a fixed set of keys and optional defaults. Fields hold values and are never reassigned. Functions on the module return a new struct rather than changing one. References: [Elixir structs](https://elixir.hexdocs.pm/structs.html). ### function An Elixir function identified by its module, name and arity. Functions of one name and different arities are different functions. A name ending in ! raises on failure, and a name ending in ? returns a boolean. References: [Elixir functions](https://elixir.hexdocs.pm/modules-and-functions.html). ### method A callback that a behaviour declares and an implementing module defines. A callback is called through the implementing module, not through the behaviour that declares it. References: [Elixir behaviour callbacks](https://elixir.hexdocs.pm/typespecs.html#behaviours). ### property A field of an Elixir struct, read with dot access or pattern matching. A field has no accessor function; structs are plain maps, so the value is stored as the field holds it. References: [Elixir structs](https://elixir.hexdocs.pm/structs.html). ### typealias An Elixir type declared with @type or @opaque, named and given an arity. Types document values for readers and tools. They are not checked when a function runs. References: [Elixir user-defined types](https://elixir.hexdocs.pm/typespecs.html#user-defined-types). ### exception An Elixir struct declared with defexception, which can be raised and rescued. The struct also carries the fields of the error. A bang function raises it; the plain function returns it in an error tuple. References: [Elixir exceptions](https://elixir.hexdocs.pm/Kernel.html#defexception/1). ## Modifiers Modifiers add information about calling, implementing, or accessing a declaration. Their precise effect follows the language and the signature. ### opaque An Elixir type declared with @opaque, whose structure callers must not depend on. Other modules should build and inspect the value only through the declaring module’s functions. References: [Elixir user-defined types](https://elixir.hexdocs.pm/typespecs.html#user-defined-types). ### macro An Elixir macro, defined with defmacro and expanded at compile time. A caller must require or import the defining module before using the macro. References: [Elixir macros](https://elixir.hexdocs.pm/Kernel.html#defmacro/2). ### abstract A callback of a behaviour, declared without a body. References: [Elixir behaviour callbacks](https://elixir.hexdocs.pm/typespecs.html#behaviours). ### deprecated A declaration marked with the @deprecated attribute. The compiler warns at call sites of a deprecated function. The message names the replacement when the author gave one. References: [Elixir @deprecated attribute](https://elixir.hexdocs.pm/Module.html#module-deprecated-since-v1-6-0). ### overload A function with several @spec clauses, each describing one accepted combination of argument types. The clauses describe one function. Which clause applies depends on the arguments, not on a separate definition. References: [Elixir function specifications](https://elixir.hexdocs.pm/typespecs.html#defining-a-specification). ## Package context Package labels identify where an API is supplied. ### package The Hex package supplying this API. A package name and its application name are the same in a Mix dependency, and the module names it defines are independent of both. References: [Hex packages](https://hex.pm/docs/usage). --- # Examples Source: https://libtmux.org/en/elixir/pr-173/examples/ > Run complete programs with their documented setup and cleanup. Run complete programs with their documented setup and cleanup. - [Capture a pane and read it](https://libtmux.org/en/elixir/pr-173/examples/capture-and-read/): Capture a graph, select a pane and read it through one-shot and control commands. --- # Capture a pane and read it Source: https://libtmux.org/en/elixir/pr-173/examples/capture-and-read/ > Capture a graph, select a pane and read it through one-shot and control commands. Capture once, then query the immutable result with no more tmux commands. Install the published package as shown in the [README](https://libtmux.org/en/elixir/pr-173/guides/overview/#installation), then save this program as `capture_and_filter.exs`. It starts a private server with [`Server.with_owned/2`](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/owned-server.md), so it runs as it is: ```elixir alias LibTmux.{Selection, Server, Snapshot} tmux = System.find_executable("tmux") || raise "tmux is not on PATH" Server.with_owned([executable: tmux], fn server -> {:ok, _} = Server.new_session(server, "demo", command: {:argv, ["/bin/cat"]}) {:ok, snapshot} = Server.snapshot(server) active_ids = snapshot |> Snapshot.panes() |> Selection.where(active: true) |> Enum.map(& &1.id) IO.puts(JSON.encode!(%{active_panes: active_ids})) end) ``` Run it with tmux 3.3 or newer on `PATH`: ```console $ mix run capture_and_filter.exs ``` It prints the IDs of the active panes, in numeric order, as JSON. - To capture a server that already runs, build the descriptor with [`Server.new/1`]() in place of [`Server.with_owned/2`](), passing `socket:` or `socket_name:`. - With neither, [`Server.new/1`]() reads `LIBTMUX_SOCKET_PATH`, then `LIBTMUX_SOCKET` (a socket name). With neither set, it passes tmux no socket, and tmux uses its default socket. - A pane is active within its physical window. This does not choose one session's active window. Linked windows do not duplicate their panes. - [`Server.new/1`]() builds a descriptor with no I/O. [`Server.snapshot/2`]() runs bounded one-shot reads, without attaching a control client or creating a missing server. - [`Selection.where/2`]() and `Enum.map/2` use the captured graph. - Capture covers an interval, not an atomic tmux transaction. Capture again for fresh state. - The `{:ok, snapshot}` match makes a capture error visible. Production code can handle `{:error, %LibTmux.Error{}}`. - Default capture budgets: 5000ms, 512 commands, 1024 contextual topology rows, 64 KiB per response and 8 MiB in total. A limit failure returns an error, not a partial graph. Next: [filter and select](https://libtmux.org/en/elixir/pr-173/guides/filtering/), [one-shot actions](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/one-shot-actions.md) or [managed control](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/managed-control.md). ## Choose a socket Build a server descriptor from a socket path, a socket name or an environment map. Constructing the descriptor performs no I/O. ```elixir alias LibTmux.Server tmux = System.find_executable("tmux") || raise "tmux is not on PATH" by_path = Server.new(executable: tmux, socket: "/run/user/1000/work.sock") by_name = Server.new(executable: tmux, socket_name: "work") from_variable = Server.new(executable: tmux, env: %{"LIBTMUX_SOCKET" => "work"}) path_env = %{"LIBTMUX_SOCKET_PATH" => "/tmp/w.sock"} from_path_variable = Server.new(executable: tmux, env: path_env) default = Server.new(executable: tmux, env: %{}) %Server{socket: "/run/user/1000/work.sock", socket_name: nil} = by_path %Server{socket: nil, socket_name: "work"} = by_name %Server{socket: nil, socket_name: "work"} = from_variable %Server{socket: "/tmp/w.sock", socket_name: nil} = from_path_variable %Server{socket: nil, socket_name: nil} = default IO.puts( JSON.encode!(%{ by_path: by_path.socket, by_name: by_name.socket_name, from_variable: from_variable.socket_name, from_path_variable: from_path_variable.socket, default: "tmux chooses" }) ) ``` --- # Guides Source: https://libtmux.org/en/elixir/pr-173/guides/ > Connect to tmux and work with its sessions, windows, and panes. Connect to tmux and work with its sessions, windows, and panes. - [Getting started](https://libtmux.org/en/elixir/pr-173/guides/overview/): Add the Hex package, check the Elixir, OTP and tmux requirements, and run an example. - [Attaching to tmux](https://libtmux.org/en/elixir/pr-173/guides/attaching-to-tmux/): Connect to an existing socket and leave its server running. - [Filter captured values](https://libtmux.org/en/elixir/pr-173/guides/filtering/): Select observed values with portable keyword and operator filters. --- # Getting started Source: https://libtmux.org/en/elixir/pr-173/guides/overview/ > Add the Hex package, check the Elixir, OTP and tmux requirements, and run an example.

Hex.pm · API reference · HexDocs · Documentation

libtmux libtmux.org license

Drive tmux from Elixir: [capture][snapshot] sessions, windows and panes as an immutable snapshot, [filter][where] it with plain data, then rename, split and type through domain actions. ## Packages ### [libtmux](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib) Capture, filter and act on tmux sessions, windows and panes. [API reference](https://libtmux.org/en/elixir/latest/reference/) · [Hex package](https://hex.pm/packages/libtmux) · [Changelog](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/CHANGELOG.md) ### [libtmux_workspace](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/packages/workspace) Plan and apply session and window descriptions against a running tmux server. The [package guide](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/packages/workspace/README.md) is available in the source checkout. ### [libtmux_mcp](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/packages/mcp) Let an MCP client inspect tmux and apply explicitly authorized workspace plans over standard I/O. The [package guide](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/packages/mcp/README.md) is available in the source checkout. ## Test a program in a pane From a repository checkout with the [requirements](https://libtmux.org/en/elixir/pr-173/guides/overview/#installation) installed and dependencies fetched, run the notebook test on a private tmux server. ```console $ mix run examples/interactive.exs ``` The test prints `SAVED 1`. The [program](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/examples/interactive.exs) waits for the notebook's `READY` line, types a note with [`Pane.send_text!/4`][text], and submits it with [`Pane.send_keys!/4`][keys]. Its `await_line` helper reads the screen until it sees the receipt or the wait expires. ```elixir Pane.send_text!(server, pane, "buy milk") unless omit_enter?, do: Pane.send_keys!(server, pane, ["Enter"]) InteractiveDemo.await_line(server, pane, "SAVED 1", timeout) ``` Run with `--omit-enter` to skip the named key. The text reaches the pane. The notebook still waits for a complete line, so the test prints its last screen and exits with status 124. ```console $ mix run examples/interactive.exs --omit-enter ``` ```text Timed out after 650 ms waiting for SAVED 1. Last screen: READY Type a note and press Enter. ``` The example stops its private server and removes the notebook's temporary data in both cases. ## Installation Add the package to your Mix dependencies: ```elixir {:libtmux, "~> 0.1"} ``` Fetch dependencies: ```console $ mix deps.get ``` It needs: - Elixir 1.20.4 or later in the 1.20 line, compiled for OTP 29 - OTP 29.1.2 or later in the 29 line - tmux 3.3 or newer - Linux and a C compiler, which builds a small helper - no third-party runtime packages and no NIF The exact floors and tested releases are in [Packages and support](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/implementation.md#packages-and-support). [Ship a CLI](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/ship-a-cli.md) covers a Mix consumer, a relocated release and the escript delivery choices for owned and existing tmux servers. ## Try the examples The snippets below form one [executable program](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/examples/readme.exs). It starts a private tmux server and stops it afterward. Follow the [checkout setup](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/.github/CONTRIBUTING.md#setup), then run the example with tmux on `PATH`. ```console $ mix run examples/readme.exs ``` - Your own tmux sessions are untouched: the server has its own directory and never sees `TMUX`. - Examples that run tmux start their own private server. The pure examples run directly in the VM. No checkout? The [standalone demo](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/standalone-demo.md) installs the package from Hex. ## Start a private server [`Server.with_owned/2`][with-owned] starts a private tmux server, passes it to your function and stops it when the function returns or raises. To own a server across calls, use [`Server.start/1`][start] and [`Server.stop/2`][stop]. The [owned-server guide](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/owned-server.md) runs the complete window creation and retirement example. ## Choose the server Use [`Server.new/1`][server-new] to describe an existing server. Pass `:socket` for an absolute socket path or `:socket_name` for a name. Without either, the descriptor checks `LIBTMUX_SOCKET_PATH` and then `LIBTMUX_SOCKET`. With both variables unset, tmux chooses the server. See [Choose a socket](https://libtmux.org/en/elixir/pr-173/examples/capture-and-read/#choose-a-socket) for the executable example. ## Check tmux features on the daemon ### [`Server.capabilities/2`][server-capabilities]: decide from the daemon's release [`Capabilities.require/2`][capabilities-require] returns a supported native primitive or a refusal before dispatch. [`Control.capabilities/2`][control-capabilities] reads through an established control connection. Run the [capabilities example](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/examples/capabilities.exs) to check event-wait support. It prints `"available"` on tmux 3.8 and `"refused"` on tmux 3.3. More: [Check daemon features](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/capabilities.md). ## Find sessions, windows and panes ### [`Server.snapshot!/2`][snapshot]: what tmux has now The snippets from here on run inside the function that [`Server.with_owned/2`](https://libtmux.org/en/elixir/pr-173/guides/overview/#start-a-private-server) calls, so `server` is its private server. One call captures every session, window and pane as an immutable graph. [`Snapshot.sessions/1`][snapshot-sessions], [`Snapshot.windows/1`][snapshot-windows] and [`Snapshot.panes/1`][snapshot-panes] pick a type, and [`Selection.where/2`][where] filters it. None of them calls tmux again. ```elixir alias LibTmux.{Selection, Snapshot} snapshot = Server.snapshot!(server) active_ids = snapshot |> Snapshot.panes() |> Selection.where(active: true) |> Enum.map(& &1.id) ``` `active_ids` is `["%0"]`: the demo server starts with one pane. Capture again when you need fresh state. More: [Captured state](https://libtmux.org/en/elixir/pr-173/concepts/observations/) and [compare two snapshots](https://libtmux.org/en/elixir/pr-173/concepts/observations/#compare-two-snapshots). ### [`Selection.where/2`][where]: filter by data Criteria are keywords or maps, and can test related panes. [`Filter.from_json/3`][filter-json] reads the same criteria from JSON, so a filter can come from a file or a request. [`Selection.filter/2`][filter] takes an Elixir function instead. ```elixir alias LibTmux.{Filter, Pane, Selection, Snapshot} windows = snapshot |> Snapshot.windows() |> Selection.where(panes: [some: [active: true, current_command: "cat"]]) |> Enum.map(& &1.id) json = """ {"version":1,"entity":"pane", "where":{"active":true,"currentCommand":{"in":["cat","nvim"]}}} """ {:ok, filter} = Filter.from_json(Pane, json) pane_ids = snapshot |> Snapshot.panes() |> Selection.where(filter) |> Enum.map(& &1.id) ``` `windows` is `["@0"]` and `pane_ids` is `["%0"]`. One pane must meet both conditions inside `some`. More: [Filtering](https://libtmux.org/en/elixir/pr-173/guides/filtering/). ## Rename a window ### [`Window.rename!/4`][rename]: change a window's name Continue with the same [`snapshot`][snapshot-type] and [`server`][server-type]. [`Selection.one!/2`][one] needs exactly one match, [`Session.active_window/2`][active-window] reads the captured link, and [`Ref.from_observation/1`][ref] turns an observation into an action target. ```elixir alias LibTmux.{Ref, Selection, Session, Snapshot, Window} session = snapshot |> Snapshot.sessions() |> Selection.one!(id: session_id) window = Session.active_window(snapshot, session) {:ok, session_ref} = Ref.from_observation(session) {:ok, window_ref} = Ref.from_observation(window) Window.rename!(server, window_ref, "editor", session: session_ref) ``` It returns `:ok` once tmux acknowledges the command. `session:` names the session whose link to the window to use. The old snapshot keeps the old name. More: [One-shot actions](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/one-shot-actions.md). ## Split a pane, send input and read the screen ### [`Control.with_connection/2`][scope]: one connection for many commands It attaches a control client to an existing session, runs your callback, and closes the client. [`Pane.split!/3`][split] returns the new pane's ID and a bound reference. [`Pane.send_text!/4`][text] sends literal text and [`Pane.send_keys!/4`][keys] sends named keys. After the scope closes, [`Pane.capture!/3`][capture] reads the new pane's screen through the `server`. ```elixir alias LibTmux.{Control, Pane, Ref, Selection, Snapshot} pane = snapshot |> Snapshot.panes() |> Selection.one!(window_id: window.id, active: true) {:ok, pane_ref} = Ref.from_observation(pane) {:ok, {created_id, created}} = Control.with_connection( [server: server, session: {:existing, session.id}, lane: :host_qualified], fn control -> split_opts = [axis: :horizontal, command: {:argv, ["/bin/cat"]}] %{id: id, ref: created} = Pane.split!(control, pane_ref, split_opts) Pane.send_text!(control, created, "hello") Pane.send_keys!(control, created, ["Enter"]) {id, created} end ) screen = Pane.capture!(server, created, max_bytes: 4096) ``` The program prints: ```text {"window":"editor","active_panes":["%0"],"created_pane":"%1","connection_retired":true} ``` - `{:argv, ["/bin/cat"]}` runs a program directly; `{:shell, "command"}` goes through a shell. - An acknowledgement does not mean the program has read its input, so [`screen`]() may not show `hello` yet. - [`Pane.capture!/3`]() runs one command through the `server`; a control connection refuses it. - `lane: :host_qualified` says you control this server's hooks and aliases. A server from [`Server.start/1`]() does. Read the managed-control guide before using another host. More: [Managed control](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/managed-control.md). ## Errors and recovery ### [`Action.CompletionError`][completion-error]: what went wrong Actions return `{:ok, result}` only when the command completes; the bang forms raise instead. A command that times out may still have taken effect, so inspect it before you retry. See [diagnose capture work](https://libtmux.org/en/elixir/pr-173/concepts/observations/#diagnose-capture-work) for the commands and retained response bytes a snapshot used before it returned. More: [Recovery](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/recovery.md), [Mental model](https://libtmux.org/en/elixir/pr-173/concepts/mental-model/). ## Guides - [Worked API examples](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/api-examples.md) show the public calls for each task. - [Filtering](https://libtmux.org/en/elixir/pr-173/guides/filtering/): predicates, relations and finding one match. - [One-shot actions](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/one-shot-actions.md): rename, split, input and screen capture. - [Managed control](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/managed-control.md): one connection, many commands. - [Daemon features](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/capabilities.md): release decisions and observation boundaries. - [Owned programs in tmux panes](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/owned-program-concept.md). Run, wait for and cancel an application on tmux 3.8. - [Mental model](https://libtmux.org/en/elixir/pr-173/concepts/mental-model/): snapshots, references and results. - [API reference](https://libtmux.org/en/elixir/latest/reference/): functions and types. ## Support and status - **Alpha.** Releases are numbered `0.1.N`. Any release may change or remove exported functions; the [changelog](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/CHANGELOG.md) marks each break. Pin an exact version to avoid one. - **Linux.** The helper that owns tmux processes needs Linux. - **tmux.** 3.3 or newer. ## What it leaves out - **A query planner.** Selections run locally over a snapshot; `Query`, `Batch` and `Plan` are planned. - **Change notifications.** `Observation` and `Tracker` are planned. ## AI policy The [documentation index for agents](https://libtmux.org/en/elixir/latest/llms.txt) and [full Markdown reference](https://libtmux.org/en/elixir/latest/llms-full.txt) cover the published Elixir API. Use these packages with AI tools as you like. When contributing, check what you submit and wait for a maintainer's invitation before preparing a pull request. See the [AI policy](https://libtmux.org/en/meta/ai-policy/), also kept as [AI_POLICY.md](https://github.com/libtmux/.github/blob/HEAD/AI_POLICY.md). ## Contributing See [Contributing](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/.github/CONTRIBUTING.md) for development setup and checks, and [Writing](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/.github/WRITING.md) for documentation conventions. Part of the [libtmux.org](https://libtmux.org/) family alongside Python [`libtmux`](https://github.com/tmux-python/libtmux), sibling [language ports](https://github.com/libtmux), and [tmux](https://github.com/tmux/tmux). [Artwork](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/assets/README.md) · [MIT License](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/LICENSE). [with-owned]: https://libtmux.org/en/elixir/latest/reference/libtmux-server-with_owned-2/ [start]: https://libtmux.org/en/elixir/latest/reference/libtmux-server-start-1/ [stop]: https://libtmux.org/en/elixir/latest/reference/libtmux-server-stop-2/ [snapshot]: https://libtmux.org/en/elixir/latest/reference/libtmux-server-snapshot-bang-2/ [snapshot-type]: https://libtmux.org/en/elixir/latest/reference/libtmux-snapshot/ [snapshot-sessions]: https://libtmux.org/en/elixir/latest/reference/libtmux-snapshot-sessions-1/ [snapshot-windows]: https://libtmux.org/en/elixir/latest/reference/libtmux-snapshot-windows-1/ [snapshot-panes]: https://libtmux.org/en/elixir/latest/reference/libtmux-snapshot-panes-1/ [server-type]: https://libtmux.org/en/elixir/latest/reference/libtmux-server/ [server-new]: https://libtmux.org/en/elixir/latest/reference/libtmux-server-new-1/ [server-capabilities]: https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/capabilities.md#observe-the-server-and-connection [control-capabilities]: https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/capabilities.md#preserve-the-observation-boundary [capabilities-require]: https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/capabilities.md#check-a-named-primitive [where]: https://libtmux.org/en/elixir/latest/reference/libtmux-selection-where-2/ [filter]: https://libtmux.org/en/elixir/latest/reference/libtmux-selection-filter-2/ [filter-json]: https://libtmux.org/en/elixir/latest/reference/libtmux-filter-from_json-3/ [one]: https://libtmux.org/en/elixir/latest/reference/libtmux-selection-one-bang-2/ [active-window]: https://libtmux.org/en/elixir/latest/reference/libtmux-session-active_window-2/ [ref]: https://libtmux.org/en/elixir/latest/reference/libtmux-ref-from_observation-1/ [rename]: https://libtmux.org/en/elixir/latest/reference/libtmux-window-rename-bang-4/ [scope]: https://libtmux.org/en/elixir/latest/reference/libtmux-control-with_connection-2/ [split]: https://libtmux.org/en/elixir/latest/reference/libtmux-pane-split-bang-3/ [text]: https://libtmux.org/en/elixir/latest/reference/libtmux-pane-send_text-bang-4/ [keys]: https://libtmux.org/en/elixir/latest/reference/libtmux-pane-send_keys-bang-4/ [capture]: https://libtmux.org/en/elixir/latest/reference/libtmux-pane-capture-bang-3/ [completion-error]: https://libtmux.org/en/elixir/latest/reference/libtmux-action-completionerror/ --- # Attaching to tmux Source: https://libtmux.org/en/elixir/pr-173/guides/attaching-to-tmux/ > Connect to an existing tmux server and find a session with Elixir. Select an explicit socket, capture the existing server, and find the `work` session. The program prints its name and leaves the server running. A missing server or session ends the program with an error. This controls tmux from Elixir. To open a session in your terminal, use [`tmux attach-session`](https://libtmux.org/en/tmux/latest/manual/attach-session/); the [shared guide](https://libtmux.org/en/tmux/guides/attaching-to-tmux/) covers interactive attachment and detaching. ## Connect to an existing server Save the complete program as `connect.exs`. The environment variable `LIBTMUX_SOCKET_PATH` selects the existing server, and `print_work` connects to it and finds `work`. Without the variable, the program starts a private server of its own in a new temporary directory, creates `work` with [`new_session!`](), and calls `print_work` with that socket through a second [`Server`]() value. The library works on a running server and does not start one, so the program has `tmux` start the daemon. It stops the private server with [`Server.run/3`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-server-run-3/) and removes the directory after success or failure. If the server does not stop, the program reports the error and keeps the directory. The first line installs libtmux from Hex. Its requirement, `~> 0.1`, accepts any release from 0.1.0 up to, but not including, 1.0.0. ```elixir title="connect.exs" role="program" Mix.install([{:libtmux, "~> 0.1"}]) alias LibTmux.{Command, Selection, Server, Snapshot} tmux = System.find_executable("tmux") || raise "tmux is not on PATH" print_work = fn socket -> server = Server.new(executable: tmux, socket: socket) snapshot = Server.snapshot!(server) session = snapshot |> Snapshot.sessions() |> Selection.one!(name: "work") IO.puts(session.name) end case System.get_env("LIBTMUX_SOCKET_PATH") do nil -> # No server was named: start one this program owns. id = Base.encode16(:crypto.strong_rand_bytes(8), case: :lower) dir = Path.join(System.tmp_dir!(), "libtmux-attach-" <> id) socket = Path.join(dir, "tmux.sock") owner = Server.new(executable: tmux, socket: socket) File.mkdir!(dir) File.chmod!(dir, 0o700) try do # libtmux works on a running server, so tmux starts the daemon itself. start = ~w(start-server ; set-option -s exit-empty off) {_, 0} = System.cmd(tmux, ["-S", socket, "-f", "/dev/null" | start]) Server.new_session!(owner, "work", command: {:argv, ["/bin/cat"]}) print_work.(socket) after kill = Command.new("kill-server", []) running = File.exists?(socket) stopped = not running or match?({:ok, _}, Server.run(owner, kill)) if stopped do File.rm_rf!(dir) else IO.puts(:stderr, "Cannot stop tmux; kept #{dir}") System.halt(1) end end socket -> print_work.(socket) end ``` [`Server.new/1`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-server-new-1/) describes a server that already exists and performs no I/O. [`Server.snapshot!/2`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-server-snapshot-bang-2/) reads tmux and returns captured state, or raises the structured capture error. [`Snapshot.sessions/1`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-snapshot-sessions-1/) selects sessions from that state without contacting tmux again, and [`Selection.one!/2`](https://libtmux.org/en/elixir/pr-173/reference/libtmux-selection-one-bang-2/) requires exactly one match. Reading or filtering captured values does not refresh them. The server value describes the daemon. It does not own a process to close, and the program does not destroy the caller's sessions. ## Setup and run Use an empty directory on Linux with Elixir 1.20.4 or newer, Erlang/OTP 29.1.2 or a newer 29.x release, a C11 compiler, tmux 3.3 or newer, and access to hex.pm. ```console $ elixir connect.exs ``` The program prints `work`. To use your own existing server, set `LIBTMUX_SOCKET_PATH` to its socket before running the program; it prints `work` and leaves that server running. ## Find or create a session Reading a session does not reserve its name. If your application creates a session after an unsuccessful lookup, another client may create the same name between those operations. Handle the creation error as well as the lookup. [Mental model](https://libtmux.org/en/elixir/pr-173/concepts/mental-model/) and [Observations](https://libtmux.org/en/elixir/pr-173/concepts/observations/) explain what a snapshot holds. [Capture a pane and read it](https://libtmux.org/en/elixir/pr-173/examples/capture-and-read/) is a complete program that runs against an isolated server. The [library source revision](https://github.com/libtmux/libtmux-elixir/tree/cac4252bfc52069980d47db2b7803dc9b33f36f1) records the implementation used by this example. --- # Filter captured values Source: https://libtmux.org/en/elixir/pr-173/guides/filtering/ > Select observed values with portable keyword and operator filters. Capture one [snapshot](https://libtmux.org/en/elixir/pr-173/concepts/observations/), then select from it. The examples run on a private server from [`Server.with_owned/2`](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/owned-server.md). From a checkout, with tmux on `PATH`: ```console $ mix run examples/filtering.exs ``` ```elixir editors = ["cat", "nvim", "vim"] active = snapshot |> Snapshot.panes() |> Selection.where(active: true, current_command: [in: editors]) Enum.map(active, & &1.id) ``` - Selections keep their graph and order. Enumerating one does no I/O. - `size/1` reads a cached count. - [`Enum.member?/2`]() compares elements; [`Selection.member_id?/2`]() compares native IDs. ## Select - `where/2` takes validated data. Keywords are shorthand for maps, and duplicate keys are rejected at every level. - `filter/2` takes a unary function and uses [`Enum`]() truthiness. Predicate exceptions propagate. - Both validate before scanning, even when no items remain. - `one/2` returns `{:ok, item}` or a structured `:no_match` or `:multiple_matches` error. `one!/2` raises the same error. - `one_or_nil/2` also allows zero matches. Both stop at the second match. - `exists?/2` stops at the first match. `count/2` counts matches; `size/1` returns the total. ## Predicate grammar - A bare scalar means equality; `%{equals: value}` is the same. The [generated schema](https://libtmux.org/en/elixir/pr-173/topics/schema/) lists each field's type and operators. - Numbers compare numerically and strings compare case-sensitively, with no normalization. Ordering a nullable number against a known [`nil`]() is false. - `not` negates equality. `not_in` negates membership, including known [`nil`](). - Portable regex is not supported. Native predicates may use [`Regex`](). - Fields in one object conjoin. `and` and `or` take lists of criteria and `not` takes one criteria object. An empty `and` is true; an empty `or` is false. - Separate relation quantifiers are never combined: ```elixir with_cat = Selection.where(Snapshot.sessions(snapshot), %{ panes: %{some: %{active: true, current_command: "cat"}} }) ``` That predicate needs one pane to satisfy both conditions. Two separate `some` clauses can match different panes. - `every` and [`none`]() are true for a known-empty relation; `some` is false. - [`count`]() counts the relation's identities. Physical windows and panes deduplicate; window links keep their memberships. - To-one `is: criteria` is false for known absence, and `is_not` negates it. `is: nil` means absent; `is_not: nil` means present. - A session's [`active_window`]() comes from a complete link domain and loaded active flags. Zero active links is known absence; several raise `:ambiguous_relation`. An unresolved active target stays unloaded. - Coverage checks run before evaluation, including fields behind a Boolean branch that cannot match. ## External filters - [`Filter.new/3`]() returns a validated portable value; `new!/3` raises its structured error. Applying the value keeps its constructor validation. - Prepared predicates may hold sets and closures. Portable filters hold only data. [`LibTmux.Filter.to_predicate/2`]() reuses a filter as a predicate. - [`Filter.from_json/3`]() uses built-in JSON. It rejects duplicate keys, trailing data and unknown names. - `from_wire/3` takes an already decoded map, which cannot show discarded duplicate keys. - Neither decoder creates atoms from external keys. - Encode with [`Filter.to_wire/1`](), then [`JSON.encode!/1`](). ```elixir alias LibTmux.{Filter, Pane} criteria = [active: true, current_command: [in: ["nvim", "vim"]]] {:ok, filter} = Filter.new(Pane, criteria) json = filter |> Filter.to_wire() |> JSON.encode!() {:ok, ^filter} = Filter.from_json(Pane, json) ``` The document is: ```json { "version": 1, "entity": "pane", "where": { "active": true, "currentCommand": {"in": ["nvim", "vim"]} } } ``` ## Limits Defaults: 65,536 bytes, depth 16, 1024 value nodes, 256 array elements and 8192 bytes per string. Positive integer options `max_bytes`, `max_depth`, `max_nodes`, `max_list` and `max_string_bytes` narrow or widen them. - A JSON object has at most 256 members. - Wire depth starts at root zero and counts every member and element. The ceiling is inclusive. - Native input depth counts criteria objects and bounds the normalized tree. A normalized conjunction adds no relation or Boolean nesting; disjunctions, negations and relation children do. - Wire budgets also cover the versioned envelope. - Errors carry the affected path, including Boolean and membership indexes. An early parser-limit error can name only the root. Filters run locally on a captured snapshot. Server-side query planning is not implemented. --- # Linking and consuming our docs Source: https://libtmux.org/en/elixir/pr-173/meta/linking/ > Find documentation exports for search engines, bots, LLMs and other documentation sites. We welcome bots, search engines, SEO tools, LLMs and other clients to use our documentation. Read a page in your browser, fetch its Markdown, discover pages through a manifest, or link to documented objects from another site. ## Choose an export The page footer links to the exports for its documentation tree. Use those links to select a language, version or preview. | File or format | Use it for | | --- | --- | | [llms.txt](https://libtmux.org/en/llms.txt) | Discover guides, API references and agent prompts through a Markdown index. | | [llms-full.txt](https://libtmux.org/en/llms-full.txt) | Fetch the guides together as Markdown. API references are linked separately. | | [docs.json](https://libtmux.org/en/docs.json) | Discover page titles, URLs, descriptions, headings and Markdown URLs in a structured manifest. | | Markdown | Read one page as text using its footer's **Markdown** link. | | Raw source | Inspect the source file using its footer's **Raw source** link, where available. | | [objects-full.inv](https://libtmux.org/en/objects-full.inv) | Resolve Sphinx references across shared docs, each port's default version, or its latest until the default has published a catalog, and tmux reference versions. | | objects.inv | Resolve Sphinx references within one port and version, or one tmux documentation tree. | | [targets.json](https://libtmux.org/en/targets.json) | Browse inventory keys, display names and destination URLs as JSON. A scoped catalog sits beside each root inventory. The root one lists fallbacks and ports left out. | The root exports above cover the assembled site. Port exports describe the selected port and version. For a single API declaration, start with `docs.json` and follow its reference and symbol-index links. ## Link from Sphinx The [Intersphinx guide](https://libtmux.org/en/meta/intersphinx/) explains how to configure inventories, choose native roles or portable labels, and preserve references when a page moves or changes its title. Browse [Intersphinx examples](https://libtmux.org/en/meta/intersphinx/examples/) for copyable RST and MyST references to library APIs, tmux C declarations, hooks, format variables, CLI commands and schema fields, paired with their destinations. ## Discover and index pages Use the [sitemap](https://libtmux.org/en/sitemap-index.xml) to discover indexable pages. Follow [robots.txt](https://libtmux.org/robots.txt) and each page's robots metadata: pull-request previews, component demos and search-index shards are excluded from crawling, and alternate versions can carry `noindex`. Choose a versioned documentation tree when a reference needs a particular release. The full inventory follows each port's advertised default; a port's `objects.inv` describes the selected version. --- # Link to libtmux from Sphinx Source: https://libtmux.org/en/elixir/pr-173/meta/intersphinx/ > Use Intersphinx inventories to reference libtmux APIs and documentation. Sphinx can resolve references to libtmux APIs, guides, headings, MCP objects, schema fields, and other documented targets. The footer links to the full inventory and the inventory for the page's port or tmux version. Browse [Intersphinx examples](https://libtmux.org/en/meta/intersphinx/examples/) for copyable RST and MyST references paired with their destinations. For Markdown exports, manifests and crawler discovery, see [Linking and consuming our docs](https://libtmux.org/en/meta/linking/). ## Configure Intersphinx Enable the built-in extension in your project's `conf.py`: Python's [`None`]() discovers `objects.inv` at the configured base URL. The port mapping above selects the Python `latest` tree. Copy the base URL of another port or version to select its inventory. The full inventory includes shared documentation, the configured default version of each assembled port, and distinct tmux reference versions. It is generated after site assembly. Each port inventory includes the rendered targets in that exact version. The tmux inventory includes the shared tmux guides and the latest CLI manual, options, hooks, formats, and C source reference. A version mapping such as `tmux-3-7c` includes only that release's manual, catalog, and C declarations. Manual and C reference pages link to the same version inventory in the footer. Use mapping names without dots when writing MyST reference roles. ## Choose a reference Every exported target has a portable label that works with `std:ref`, without installing a language or MCP domain. Open `targets.json` beside the inventory and copy its [`key`](). Its `href` and `display` identify the destination. For example, the Python [`libtmux.Pane`]() declaration has this reStructuredText reference: ```rst :external+libtmux:ref:`Pane ` ``` With MyST enabled in your project, the same label works in Markdown: ```markdown {external+libtmux:ref}`Pane ` ``` Native Python, C++, JavaScript, and C objects also have aliases for their built-in roles. A scoped Python inventory supports: ```rst :external+libtmux-python:py:class:`libtmux.Pane` ``` The tmux mapping provides native C roles and portable manual references: ```rst :external+tmux:c:struct:`cmd` :external+tmux:ref:`capture-pane ` ``` Command options also work with Sphinx's program context: ```rst .. program:: tmuxp load :external+libtmux-python:option:`--append` ``` The full inventory qualifies native names by port, such as [`py:libtmux.Pane`](). A fully qualified alias includes the product too: [`py:core:libtmux.Pane`](). Short aliases are offered only when they identify one destination. Configuration values, command options, environment variables, and glossary terms use standard-domain types where their renderers identify those semantics. ## Stable labels A portable key contains `scope:product:category:identity`. Its encoding preserves uppercase letters, punctuation, and Unicode, because `std:ref` lowercases targets. `%50ane` and `pane` therefore remain distinct. Copy the key from the catalog without decoding its percent escapes. Keys are independent of display titles and destination URLs. API public IDs, protocol wire identities, JSON Pointers, named parameters, and native method identities supply their names. Authored documents can retain `inventoryId` and explicit HTML fragment IDs when their titles or routes change. Contributors preserve renamed keys in the inventory alias catalog and use the existing page redirect mechanism for retired routes. ### Preserve published links If `meta/intersphinx.md` moves to `meta/linking.md`, retain its logical ID and list the retired route in the new page's frontmatter: ```yaml inventoryId: intersphinx aliases: - meta/intersphinx ``` The document key remains `site:core:doc:intersphinx`, and the old route redirects to the new page. Retain existing heading fragment IDs when their text changes. When an identity or fragment changes intentionally, map the former keys to current targets in `site/src/data/inventory-aliases.json`. For example, choosing `inventoryId: linking` and changing `stable-labels` to `stable-references` needs these entries: ```json [ { "scope": "site", "from": "site:core:doc:intersphinx", "to": "site:core:doc:linking" }, { "scope": "site", "from": "site:core:heading:intersphinx%23stable-labels", "to": "site:core:heading:linking%23stable-references", "fragment": "stable-labels" } ] ``` The document entry preserves `std:ref` and `std:doc` references. The heading entry preserves `std:ref`; `fragment` also installs the retired HTML anchor at the new destination. Keep the route alias too: inventory aliases do not redirect retired URLs. Copy `to` from the current target catalog. Retain earlier `from` entries and update their destinations when renaming again. Former native role names, such as a Python class name, need preservation in the native metadata. Existing `objects.inv` and `reference/objects.inv` endpoints remain compatibility exports. New integrations should use the full inventory, a port's root inventory, or a tmux root inventory to obtain the complete target catalog and case-safe labels. See the [Sphinx Intersphinx documentation](https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html) for named inventories and cross-reference syntax. --- # Intersphinx examples Source: https://libtmux.org/en/elixir/pr-173/meta/intersphinx/examples/ > Compare Sphinx and MyST references to APIs, tmux C declarations, hooks, format variables, CLI commands and schema fields. import { referenceHref } from '../../../../lib/api-models' Copy a reference and compare its destination below. These examples cover native language roles, portable labels, full and scoped inventories, and links into tmux C declarations, hooks, format variables and CLI commands. ## Configure the inventories Add these mappings to your Sphinx project's `conf.py`: Python's [`None`]() discovers `objects.inv` at the mapping's base URL. The full inventory uses each port's advertised default version. The `py` mapping explicitly selects `latest`; `tmux` selects the latest tmux manual and C reference. Use the root URL from an inventory's footer link when selecting a preview or another release. ## Native Python roles A named inventory selects the Python tree: ```rst :external+py:py:class:`libtmux.Pane` ``` Destination: [Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). The full inventory qualifies native names by port: ```rst :external+full:py:class:`py:libtmux.Pane` ``` Destination: Pane in the Python default version. For automatic lookup, use the ordinary role. A local definition takes precedence over Intersphinx: ```rst :py:class:`libtmux.Pane` ``` Destination: [Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). ## Portable labels Portable labels work with the standard reference role, including languages that have no built-in Sphinx domain. Copy the key from `targets.json`. ```rst :external+full:ref:`Pane ` :external+py:ref:`Pane ` ``` Destinations: Full inventory: Pane, [Scoped inventory: Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). The external role searches the configured inventories without selecting one. This native name is unqualified only in the scoped Python inventory: ```rst :external:py:class:`libtmux.Pane` ``` Destination: [Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). ## MyST roles and inventory URLs Enable `myst_parser` alongside [`sphinx.ext.intersphinx`](https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html) for Markdown sources. Named roles accept the same targets as reStructuredText: ```markdown {external+py:py:class}`libtmux.Pane` ``` Destination: [Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). Portable labels retain their percent escapes inside reference roles: ```markdown {external+full:ref}`Pane ` ``` Destination: Pane in the Python default version. MyST's inventory URL syntax also supports native aliases: ```markdown [Pane](inv:py:py:class#libtmux.Pane) ``` Destination: [Pane](https://libtmux.org/en/py/latest/reference/libtmux-pane/#libtmux.Pane). Use role syntax for percent-encoded portable keys: MyST normalizes escapes in `inv:` URLs. Keep mapping names free of dots, as in `tmux-3-7c`, so MyST can parse the role name. When using an inventory URL, specify its domain and object type if a name is both a document and a label. ## tmux C declarations The tmux mapping provides Sphinx's built-in C roles: ```rst :external+tmux:c:struct:`cmd` :external+tmux:c:func:`cmd_find_target` ``` Destinations: [cmd](https://libtmux.org/en/tmux/latest/reference/c-struct-cmd/#c%3Astruct%3Acmd), [cmd_find_target](https://libtmux.org/en/tmux/latest/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target). Select a release with its own mapping. The full inventory also offers version-qualified native aliases: ```rst :external+tmux-3-7c:c:func:`cmd_find_target` :external+full:c:func:`tmux@3.7c:cmd_find_target` :external+full:c:func:`tmux@latest:cmd_find_target` ``` Destinations: [Scoped: cmd_find_target in 3.7c](https://libtmux.org/en/tmux/3.7c/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target), [Full: cmd_find_target in 3.7c](https://libtmux.org/en/tmux/3.7c/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target), [Full: cmd_find_target in latest](https://libtmux.org/en/tmux/latest/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target). MyST supports the same C roles and a typed inventory URL: ```markdown {external+tmux:c:struct}`cmd` {external+tmux:c:func}`cmd_find_target` {external+full:c:func}`tmux@3.7c:cmd_find_target` [cmd_find_target](inv:tmux:c:function#cmd_find_target) ``` Destinations: [MyST: cmd](https://libtmux.org/en/tmux/latest/reference/c-struct-cmd/#c%3Astruct%3Acmd), [MyST: cmd_find_target](https://libtmux.org/en/tmux/latest/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target), [MyST full: cmd_find_target in 3.7c](https://libtmux.org/en/tmux/3.7c/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target), [Inventory URL: cmd_find_target](https://libtmux.org/en/tmux/latest/reference/c-function-cmd_find_target/#c%3Afunction%3Acmd_find_target). The C reference links each declaration to its source file and revision. Portable labels also address its signatures, parameters, and sections. ## tmux hooks Link a hook name to its catalog page with a portable label. The same key works in the scoped tmux inventory and the full inventory: ```rst :external+tmux:ref:`after-new-session ` :external+full:ref:`after-new-session ` ``` Destinations: [Scoped: after-new-session](https://libtmux.org/en/tmux/latest/catalog/hooks/after-new-session/), [Full: after-new-session](https://libtmux.org/en/tmux/latest/catalog/hooks/after-new-session/). In MyST, use the same key inside a reference role. Preserve its percent escapes: ```markdown {external+tmux:ref}`after-new-session ` {external+full:ref}`after-new-session ` ``` Destinations: [MyST scoped: after-new-session](https://libtmux.org/en/tmux/latest/catalog/hooks/after-new-session/), [MyST full: after-new-session](https://libtmux.org/en/tmux/latest/catalog/hooks/after-new-session/). ## tmux formats Link a format variable such as [`#{session_name}`](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/) to its catalog entry: ```rst :external+tmux:ref:`session_name ` :external+full:ref:`session_name ` ``` Destinations: [Scoped: session_name](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/), [Full: session_name](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/). The MyST references select the same scoped or full inventory: ```markdown {external+tmux:ref}`session_name ` {external+full:ref}`session_name ` ``` Destinations: [MyST scoped: session_name](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/), [MyST full: session_name](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/). ## tmux CLI manual The same tmux inventory covers command pages: ```rst :external+tmux:ref:`capture-pane ` ``` Destination: [capture-pane](https://libtmux.org/en/tmux/latest/manual/capture-pane/). The document role works when the target is a whole page: ```rst :external+tmux:doc:`Full manual ` ``` Destination: [Full tmux manual](https://libtmux.org/en/tmux/latest/manual/full/). Select a command's manual page with the document role. Its portable key also works in the full inventory: ```rst :external+tmux:doc:`tmux new-session ` :external+full:doc:`tmux new-session ` ``` Destinations: [Scoped: new-session](https://libtmux.org/en/tmux/latest/manual/new-session/), [Full: new-session](https://libtmux.org/en/tmux/latest/manual/new-session/). Use the same document role in MyST: ```markdown {external+tmux:doc}`tmux new-session ` {external+full:doc}`tmux new-session ` ``` Destinations: [MyST scoped: new-session](https://libtmux.org/en/tmux/latest/manual/new-session/), [MyST full: new-session](https://libtmux.org/en/tmux/latest/manual/new-session/). ## Command options, environment variables, and terms The Python port's workspace documentation exports standard-domain objects. Set the program context before referencing an option: ```rst .. program:: tmuxp load :external+py:option:`--append` ``` Destination: [tmuxp load --append](https://libtmux.org/en/py/latest/workspace/cli/load/#arguments-and-flags-a-append). Environment variables and glossary terms use their own roles. Qualify the product when a term appears in more than one glossary: ```rst :external+py:envvar:`COLUMNS` :external+py:term:`async ` ``` Destinations: [COLUMNS](https://libtmux.org/en/py/latest/workspace/configuration/environment/#cli-and-runtime-variables-columns-lines-rows), [async](https://libtmux.org/en/py/latest/reference/glossary/#async). ## MCP tools and schema fields Portable labels also address protocol objects and individual JSON Schema fields. No custom MCP domain is required: ```markdown {external+py:ref}`Read tools batch ` {external+py:ref}`on_error ` ``` Destinations: [Read tools batch](https://libtmux.org/en/py/latest/mcp/tools/call_read_tools_batch/#mcp.tool.call_read_tools_batch), [on_error](https://libtmux.org/en/py/latest/mcp/tools/call_read_tools_batch/#mcp.tool.call_read_tools_batch.input%2Fproperties%2Fon_error). ## Shared documentation and headings The full inventory includes the shared documentation: ```rst :external+full:doc:`Inventory guide ` :external+full:ref:`Configure Intersphinx ` ``` Destinations: [Inventory guide](https://libtmux.org/en/meta/intersphinx/), [Configure Intersphinx](https://libtmux.org/en/meta/intersphinx/#configure-intersphinx). ## Local files and fallback locations Download an inventory and pass its filename as the second mapping value. The first value remains the documentation URL used in generated links: An ordered list tries a local copy before the HTTP inventory: See the [inventory guide](https://libtmux.org/en/meta/intersphinx/) for key stability and the [Sphinx Intersphinx reference](https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html) for configuration options. --- # AI policy Source: https://libtmux.org/en/elixir/pr-173/meta/ai-policy/ > Use the libtmux packages with AI tools. When contributing, check what you submit and wait for a maintainer's invitation before preparing a pull request. Last revised October 25, 2026 Use these packages with AI tools as you like. When contributing, check what you submit and wait for a maintainer's invitation before preparing a pull request. This policy covers the libraries, ports, and documentation in the [libtmux](https://github.com/libtmux) and [tmux-python](https://github.com/tmux-python) organizations, including their issues, comments, discussions, reviews, and pull requests. ## 1. For users: About these packages We encourage you to use AI tools with our libraries and documentation, including to generate code that calls the libraries. We want these projects to be useful in the way you work. Some of what we publish supports that workflow: - [MCP integrations](https://libtmux.org/en/py/latest/mcp/) that let assistants interact with tmux. - Markdown documentation and `llms.txt` and `llms-full.txt` resources linked from documentation pages. - [`AGENTS.md`]() and other repository instructions for tools working on the codebase. Use the documentation for the package, language, and version you are working with. ### How the ports are made The ports build on [tmuxp](https://tmuxp.git-pull.com/), started in 2013, and [libtmux](https://libtmux.git-pull.com/), started in 2016. Both projects predate today's LLM coding tools. Current work on the original projects and the ports uses AI assistance. Maintainers guide the design, review changes, test behavior against real tmux, and decide what ships. They remain responsible for what the projects include and maintain. ### Stability Packages in the [libtmux organization](https://github.com/libtmux) are experimental unless their README says otherwise. Names and APIs may change between releases. Pin an exact version and review changes before upgrading. ## 2. For contributors: How to report issues, ideas, suggestions, and security issues A useful issue is a contribution in its own right. Your experience helps us see what breaks, what feels awkward, and what is missing. You do not need to arrive with a patch. Open bugs, ideas, and suggestions in the repository of the package they concern. Report suspected security vulnerabilities privately using the route below. ### Bugs Tell us what you tried, what happened, and what you expected. Include a small example we can run, the library and tmux versions, and the actual output. Include relevant logs and error messages as they appeared, and distinguish what you observed from possible explanations. Bug reports are welcome whether the code you were running was handwritten or generated. Include the code that ran. A conversation transcript is usually unnecessary; include relevant prompts or tool calls when they are needed to reproduce the problem. ### Ideas and suggestions Explain what you wanted to accomplish and where the current design gets in your way. We welcome feedback on: - Usability: what was hard to find or get right, and where the documentation misled you. - Language conventions: whether a port feels natural in the language you use. - Aesthetics: how an API, a page, or an error message reads. - Missing capabilities: what you could not accomplish with the current API. If an API you expected is missing, describe the task and why that API would help. ### Security issues Report suspected security vulnerabilities privately. Use **Report a vulnerability** on the affected repository's security page where available. Include the affected package and version, the tmux version, what you observed, and reproduction steps or relevant code references if available. Distinguish verified behavior from suspected impact. Please coordinate public disclosure with us so we can investigate and, where needed, prepare a fix. Command execution explicitly requested through documented features is expected behavior and does not, by itself, establish a vulnerability. Explain any additional failure, such as data being interpreted as commands unexpectedly or an intended security boundary being crossed. ### Writing your report Short reports, typos, and imperfect English are fine. Translation and writing assistance are welcome; check that the result says what you mean and preserves the facts you observed. Your experience matters more than a polished report. ### Using AI tools If AI materially helped prepare your issue, comment, discussion, review, or pull request, say which tools you used, what they did, and what you checked yourself. Using these tools does not count against a contribution. You remain responsible for what you submit. Do not send generated code, reports, or explanations you have not checked. ### Pull requests Before preparing a pull request, open an issue or comment on an existing issue about the proposed change. Wait for a maintainer to invite a PR for an agreed scope. Opening an issue alone is not an invitation. PRs submitted without that agreement may be closed without review. Arrange security fixes through the private reporting route. Even when we agree that something should change, we may prefer to write the implementation ourselves. Review must consider correctness, supported tmux versions, language conventions, documentation, and ongoing maintenance. Checking those can take more time than writing the change, whether it was handwritten or generated. If we invite a PR, understand the changes, test them, and be able to explain them. Follow the project's contribution instructions, and describe the tests you ran and the versions you used. Generated code and tests can share the same mistake, so passing tests alone do not show that a change fits the project. Submit only material you have the right to contribute on terms compatible with the project's license. Identify outside code, tests, or text incorporated into the contribution, including material adapted with AI assistance, and provide its source and license. Keep required notices, and raise unclear permissions before including the material. These source and licensing requirements apply to maintainers too.

Acknowledgments: Informed by Pallets’ LLM and AI Policy, tmux’s AI contribution guidelines, and OpenJDK’s Interim Policy on Generative AI. Licensing references: the GNU GPL FAQ on translating code and license compatibility. All sources consulted .

--- # Third-party notices Source: https://libtmux.org/en/elixir/pr-173/meta/third-party-notices/ > Thanks to tmux's creator and contributors, with licences and attribution for the software behind libtmux.org. ## tmux First and foremost, thank you to **[Nicholas Marriott (nicm)](https://github.com/nicm)**, the creator of tmux, and to the many [tmux contributors](https://github.com/tmux/tmux/graphs/contributors). We are grateful for the work that makes tmux possible. libtmux is a separate project. Our libraries and supporting tools control a real tmux server; tmux itself provides the terminal multiplexer. This is the libtmux website. Visit the [official tmux website](https://github.com/tmux/tmux/wiki) for the upstream project and its documentation. See tmux's [COPYING file](https://github.com/tmux/tmux/blob/master/COPYING) and the copyright and permission notices in its source files for its licensing. ### tmux artwork The tmux logomark is by Jason Long. The site uses the unmodified [upstream SVG](https://github.com/tmux/tmux/blob/8f25579c5aef8d93924a20681f394e2a582fd3ad/logo/tmux-logomark.svg) under its [copyright and permission notice](https://libtmux.org/en/brand/tmux/LICENSE.txt). ## Programming-language artwork The homepage language selector uses local copies of the following artwork to identify the selected language. Each source record includes the download URL, retrieval time, file hash, copyright information and usage terms. These marks identify their respective languages and do not imply endorsement of libtmux. The SVG files are copied unchanged except for Scala, Common Lisp and Rust. Scala's and Common Lisp's empty surrounding canvases are cropped; their paths, gradients and colors are preserved, and each original SVG is retained beside the cropped copy. Rust's supplied SVG turns its mark white when the device is in dark mode. A browser does not reliably apply that rule to this site's color setting when the file is shown as an image. The rule is removed, its paths are unchanged, and the page lightens the mark on a dark theme instead. | Language | Credit and terms | Local source record | |---|---|---| | Python | Python Software Foundation. The [PSF logo terms](https://www.python.org/psf/trademarks/) permit the unaltered mark to identify Python. | [Python provenance](https://libtmux.org/en/brand/languages/py/provenance.json) | | Ruby | Copyright © 2006, Yukihiro Matsumoto. The [Ruby logo](https://www.ruby-lang.org/en/about/logo/) is licensed under [CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). | [Ruby provenance](https://libtmux.org/en/brand/languages/ruby/provenance.json) | | Lua | Copyright © 1998 Lua.org; graphic design by Alexandre Nakonechnyj. The Devicon copy carries its [MIT notice](https://libtmux.org/en/brand/languages/lua/LICENSE.txt); [Lua's logo terms](https://www.lua.org/images/) also apply. Visit [Lua.org](https://www.lua.org/). | [Lua provenance](https://libtmux.org/en/brand/languages/lua/provenance.json) | | Julia | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/julia/LICENSE.txt). The Julia mark belongs to the Julia project. | [Julia provenance](https://libtmux.org/en/brand/languages/julia/provenance.json) | | TypeScript | Microsoft. The [official branding terms](https://www.typescriptlang.org/branding/) govern the mark; the website repository licenses exclude logo and trademark rights. | [TypeScript provenance](https://libtmux.org/en/brand/languages/ts/provenance.json) | | Perl | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/perl/LICENSE.txt). The Perl mark belongs to the Perl project. | [Perl provenance](https://libtmux.org/en/brand/languages/perl/provenance.json) | | Rust | The Rust Foundation. [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) and the [Rust trademark policy](https://rustfoundation.org/policy/rust-trademark-policy/) apply. | [Rust provenance](https://libtmux.org/en/brand/languages/rs/provenance.json) | | Go | The [Go gopher](https://go.dev/blog/gopher) is by Renee French, licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). | [Go provenance](https://libtmux.org/en/brand/languages/go/provenance.json) | | C++ | Created by Jeremy Kratz and licensed by the Standard C++ Foundation under its [logo-use terms](https://isocpp.org/home/terms-of-use). | [C++ provenance](https://libtmux.org/en/brand/languages/cxx/provenance.json) | | Swift | Apple Inc., under the [Swift Logo Guidelines](https://developer.apple.com/swift/downloads/swift-logo.zip). Swift and the Swift logo are trademarks of Apple Inc. | [Swift provenance](https://libtmux.org/en/brand/languages/swift/provenance.json) | | Java | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/java/LICENSE.txt). This does not establish unrestricted rights to the underlying Java logo; [Oracle's logo terms](https://www.oracle.com/legal/logos/) apply. | [Java provenance](https://libtmux.org/en/brand/languages/java/provenance.json) | | Kotlin | Kotlin Foundation brand guidelines preserve JetBrains copyrights. The [icon-use terms](https://kotlinfoundation.org/guidelines/) permit identifying Kotlin alongside other programming-language icons. | [Kotlin provenance](https://libtmux.org/en/brand/languages/kotlin/provenance.json) | | Scala | Copyright EPFL. [Historical permission](https://groups.google.com/g/scala-user/c/bCC-R0FQn1w) covers noncommercial Scala promotion; the [general artwork-license question](https://github.com/scala/scala-lang/issues/1040) remains unresolved. | [Scala provenance](https://libtmux.org/en/brand/languages/scala/provenance.json) | | Clojure | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/clojure/LICENSE.txt). The Clojure mark belongs to the Clojure project. | [Clojure provenance](https://libtmux.org/en/brand/languages/clojure/provenance.json) | | C# | Copyright the .NET authors. [Brand-use permission](https://github.com/dotnet/brand/issues/10#issuecomment-669465301) allows the unmodified logo to represent .NET. The repository's CC0 statement covers illustrations; no blanket CC0 claim is made for the logo. | [.NET provenance](https://libtmux.org/en/brand/languages/csharp/provenance.json) | | F# | The F# Software Foundation. Its [logo terms](https://foundation.fsharp.org/logo) require unchanged shape, colors and proportions, without implying Foundation representation. | [F# provenance](https://libtmux.org/en/brand/languages/fsharp/provenance.json) | | PowerShell | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/powershell/LICENSE.txt). The PowerShell mark belongs to the PowerShell project. | [PowerShell provenance](https://libtmux.org/en/brand/languages/powershell/provenance.json) | | Erlang | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/erlang/LICENSE.txt). The Erlang mark belongs to the Erlang project. | [Erlang provenance](https://libtmux.org/en/brand/languages/erlang/provenance.json) | | Elixir | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/elixir/LICENSE.txt). The Elixir mark belongs to the Elixir project. | [Elixir provenance](https://libtmux.org/en/brand/languages/elixir/provenance.json) | | OCaml | The OCaml logo from [ocaml/ocaml-logo](https://github.com/ocaml/ocaml-logo), released under the [Unlicense](https://github.com/ocaml/ocaml-logo/blob/18923642786f54c91f9ff07140ab5738d81771d0/UNLICENSE.md); see the [OCaml brand guidelines](https://ocaml.org/logo). | [OCaml provenance](https://libtmux.org/en/brand/languages/ocaml/provenance.json) | | Haskell | Devicon collection copyright (c) 2015 konpa, with its [MIT notice](https://libtmux.org/en/brand/languages/haskell/LICENSE.txt). The Haskell mark belongs to the Haskell project. | [Haskell provenance](https://libtmux.org/en/brand/languages/haskell/provenance.json) | | Common Lisp | The Lisp alien by Conrad Barski, from his [Public Domain Lisp Logo Set](https://www.lisperati.com/logo.html): anyone may use it freely for any purpose. Common Lisp has no official logo. | [Common Lisp provenance](https://libtmux.org/en/brand/languages/lisp/provenance.json) | | Raku | The Camelia image is copyright 2009 by Larry Wall, used under the [Artistic License 2.0](https://libtmux.org/en/brand/languages/raku/LICENSE.txt). Camelia is a trademark of Larry Wall ([terms](https://github.com/Raku/mu/blob/955caf36c4387c2f39cff15552f7f69bca47f6d4/misc/camelia.txt)). | [Raku provenance](https://libtmux.org/en/brand/languages/raku/provenance.json) | ## Terminal artwork The tmux CLI selector displays the Windows Terminal artwork by Microsoft Corporation, licensed under [CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0/). The SVG is unmodified. See the [source and provenance](https://libtmux.org/en/brand/tools/terminal/provenance.json) and [copyright and license](https://libtmux.org/en/brand/tools/terminal/LICENSE.txt). ## Documentation toolchain libtmux and this site are built with open-source software. The following tools have their own licences and attribution requirements. | Tool | Licence | Role | |---|---|---| | [Astro](https://astro.build/) | MIT | The site shell | | [Tailwind CSS](https://tailwindcss.com/) | MIT | Styling | | [Pagefind](https://pagefind.app/) | MIT | Site-wide search | | [Expressive Code](https://expressive-code.com/) | MIT | Code blocks | | [Sphinx](https://www.sphinx-doc.org/) | BSD-2-Clause | Python and C++ reference | | [Furo](https://github.com/pradyunsg/furo) | MIT | Sphinx theme | | [Breathe](https://github.com/breathe-doc/breathe) | BSD-3-Clause | Doxygen XML into Sphinx | | [Doxygen](https://www.doxygen.nl/) | GPL-2.0-only | Parses C++ headers to XML | | [API Extractor](https://api-extractor.com/) | MIT | TypeScript API model | | [IBM Plex](https://github.com/IBM/plex) | OFL-1.1 | Typeface | ### A note on Doxygen Doxygen is licensed GPL-2.0-only. It runs as a build step that reads libtmux's own headers and emits XML; that XML is rendered by Breathe and Sphinx, and no Doxygen-generated HTML is published. Running a GPL program over your own input does not place its licence on the output, and libtmux does not distribute Doxygen or any modified version of it. ## Syntax highlighting Haskell code is highlighted with a copy of the TextMate grammar from the [Haskell syntax-highlighting extension](https://github.com/haskell/vscode-haskell-syntax-highlighting). Copyright © 2017 Justus Adam, licensed under [BSD-3-Clause](https://github.com/haskell/vscode-haskell-syntax-highlighting/blob/36c48222a4b6d09ff7b7747fbf7f06f14a1d3046/LICENSE). The grammar is unchanged apart from conversion to JSON; the site's repository keeps it with the license text and a source record in `site/src/vendor/haskell-grammar/`. ## Reference hosting The [PyPI blocks logo](https://pypi.org/trademarks/) is a trademark of the Python Software Foundation and identifies links to the Python Package Index. Other package-host icons use [Simple Icons](https://simpleicons.org/) (CC0-1.0). The docs.rs mark is its [`docsdotrs` icon](https://github.com/simple-icons/simple-icons/blob/16.35.0/icons/docsdotrs.svg), inlined unchanged. The book beside javadoc.io links is original artwork for this site: the host publishes no vector logo, and the mark does not imitate its favicon. Some ports deep-link to the canonical host their ecosystem already uses, rather than duplicating it here: - Rust: [docs.rs](https://docs.rs/libtmux), for each published crate - Go: [pkg.go.dev](https://pkg.go.dev/github.com/libtmux/libtmux-go/tmux) - Java, Kotlin and Scala: [javadoc.io](https://javadoc.io/doc/io.github.libtmux/libtmux) - Swift: the [Swift Package Index](https://swiftpackageindex.com/libtmux/libtmux-swift/documentation/libtmux) copy of the DocC reference Those sites are operated independently of this project and carry their own terms. ## libtmux itself Each port is MIT licensed. See the `LICENSE` file in that port's repository for the authoritative text. --- # Topics Source: https://libtmux.org/en/elixir/pr-173/topics/ > Understand object ownership, state, and operation behavior. Understand object ownership, state, and operation behavior. - [Execution ownership](https://libtmux.org/en/elixir/pr-173/topics/ownership/): Run an executable without a shell, with exit status kept apart from output. - [Command and field encoding](https://libtmux.org/en/elixir/pr-173/topics/encoding/): Render commands and decode fields without a shell or a raw newline. - [Observation and filter schema](https://libtmux.org/en/elixir/pr-173/topics/schema/): Fields, wire names, value categories and operators of each observed entity. --- # Execution ownership Source: https://libtmux.org/en/elixir/pr-173/topics/ownership/ > Run an executable without a shell, with exit status kept apart from output. [`LibTmux.Transport.OneShot.run/3`]() runs an absolute executable and argv on Linux without a shell. It returns bytes, process exit status and cleanup evidence separately. A nonzero process exit is still a completed transport result; the tmux command layer interprets that status. Public domain actions and persistent control use these ownership boundaries. Start with [one-shot actions](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/one-shot-actions.md) or [managed control](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/managed-control.md); this guide explains the lower-level contracts. The native helper supplies receive credits that an ordinary OTP Port lacks. It reads each stdout/stderr pipe only against one bounded credit; its control pipe stays responsive while output or stdin is blocked. A capture limit after delivery cannot bound an upstream mailbox while its owner is descheduled. ## Limits and results Default ceilings are 1 MiB stdout, 64 KiB stderr and 4096 retained chunks. Byte limits may be 0–16 MiB per stream; chunk limits may be 1–65,536. `max_total_bytes` limits both streams together to 0–32 MiB; its default is the sum of the stream limits. The retained prefix obeys both ceilings. Encoded cwd, argv and environment together fit a 32 KiB initialization payload. Argv has at most 2,048 entries including its executable; environment has at most 256 entries. Target environment values preserve empty strings and non-NUL bytes; inherited tmux context is removed. Requested variables apply to child `execve`; the helper inherits the trusted host environment. The timeout defaults to 5000 ms and is at most 600,000 ms. A caller can pass an existing [`LibTmux.Deadline`]() instead. Admission, startup and capture share that budget. Cleanup has a separate allowance up to 750 ms. Expiry never turns partial output into success. Overload stops the owned producer and returns a structured error with a bounded prefix. `cleanup: :retired` requires private child-retirement evidence and helper exit. Missing proof stays `:unknown`. An exit status or retryable error never authorizes replay. The worker acknowledges terminal child-retirement proof before the helper exits. The helper keeps its input open while earlier cancellation or read credits drain; after acknowledgement the worker writes nothing further. This preserves the helper's separate exit-status evidence. Missing acknowledgement uses the existing 750 ms delivery allowance. The worker monitors its caller. Caller death initiates cleanup; worker/VM death closes the helper's parent pipe. Caller settlement and retirement remain separate. Closing the reply alias also removes an already-delivered result, releasing captured bytes from the caller's mailbox. ## Accounting and scope Per-call bounds cover output bytes, chunk metadata, encoded input and private frames. Captured chunks can coexist with an assembled result; account for both copies. The helper has fixed input, queue and write buffers and bounded initialization allocations. It requests 8 KiB child pipes and a 4 KiB signal pipe. Kernel page rounding can increase the actual capacities; a resize failure rejects startup. Parent pipes and Port delivery add buffers outside the capture byte count. Aggregate accounting must measure actual pipe capacities. See [the protocol](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/c_src/README.md). This primitive has one request per worker and no shared request queue. Applications creating many independent callers need admission limits at their host/server boundary. A per-call ceiling is not a global memory ceiling. Ordinary finite descendants are killed and reaped. Uninterruptible tasks, helper SIGKILL, hostile escape and host compromise are outside that guarantee; incomplete cleanup retains uncertainty and ownership. Use `-N` for borrowed tmux servers, and choose their socket on purpose: a descriptor with no socket reaches the server `TMUX` names, or tmux's default one outside tmux. Retiring a client must not stop a borrowed server. [`LibTmux.Server.start/1`]() is the separate lifecycle for a server the program creates: it holds a foreground `tmux -D` under the helper's persistent mode, so the helper retires the server when its owner or the VM dies. Server-owned jobs still need their own ownership boundaries. On pristine tmux 3.3 and 3.3a, a control client that disconnects during startup can cause a borrowed daemon to exit, taking its sessions with it. tmux 3.7 is the first tagged release with the guard for partially initialized control clients. Older builds can carry the same guard. [Upstream change](https://github.com/tmux/tmux/commit/31c93c483afa4f94ef2091c8d9f25db4731d0e7f) ## Building and distribution Mix builds the shipped C source with a C11 compiler and Linux headers. `CC` may name one compiler executable. Dependency compilation generates the executable in the application's build `ebin` directory, which a Mix release copies with its mode intact. An external writable `MIX_BUILD_PATH` allows the source to stay read-only. Hex archives ship the source. Packed-core checks must compile and execute outside the checkout. The [CLI shipping guide](https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/docs/ship-a-cli.md) also checks a Mix release and a plain escript built with the published libtmux 0.1.3 package. ### Deploy an escript with its helper On Linux, build on a system compatible with the target architecture and C library. The target needs Erlang's `escript` command and tmux on `PATH`. In a Mix project named `escript_pane`, use the libtmux source as a path dependency and set `escript: [main_module: EscriptPane]` in `project/0`. Save the program as `lib/escript_pane.ex`. ```elixir defmodule EscriptPane do @moduledoc "Prints the pane ID from a private tmux server." alias LibTmux.{Selection, Server, Snapshot} @doc "Runs the smoke test with the helper deployed beside the escript." def main([]) do directory = :escript.script_name() |> Path.expand() |> Path.dirname() tmux = System.find_executable("tmux") || raise "tmux is not on PATH" helper = Path.join(directory, "libtmux_io") options = [executable: tmux, native_helper: helper] pane = Server.with_owned(options, fn server -> Server.new_session!(server, "demo", command: {:argv, ["/bin/cat"]}) server |> Server.snapshot!() |> Snapshot.panes() |> Selection.one!() end) IO.puts(pane.id) end end ``` Build the escript and put the two files together in a trusted directory. ```console $ MIX_ENV=prod mix escript.build ``` ```console $ mkdir -m 700 delivery ``` ```console $ install -m 755 escript_pane delivery/escript_pane ``` ```console $ MIX_ENV=prod mix run --no-start \ -e 'File.cp!(LibTmux.Transport.Native.executable(), "delivery/libtmux_io")' ``` ```console $ chmod 755 delivery/libtmux_io ``` Move the directory away from the project, then run this command from inside it. It prints `%0` after stopping its private server. ```console $ ./escript_pane ``` Pass the absolute sidecar path as `:native_helper` to [`Server.start/1`]() for a private server or to [`Server.new/1`]() for an existing server. Keep the helper from the same libtmux build at that path while tmux can respawn panes with a singleton-argv command. ### Deploy a single-file escript Use a single file when the CLI owns the server and finishes native work before it exits. In the same Mix project, set `main_module` to `EmbeddedEscriptPane` and save this program as `lib/embedded_escript_pane.ex`. It reads the compiled helper at build time, so the escript carries the bytes for the target system. ```elixir defmodule EmbeddedEscriptPane do @moduledoc "Prints a private pane ID using the helper built into the escript." alias LibTmux.{Selection, Server, Snapshot} alias LibTmux.Transport.Native @helper_path Native.executable() @external_resource @helper_path @helper File.read!(@helper_path) @doc "Runs the server with an embedded helper in its private directory." def main([]) do tmux = System.find_executable("tmux") || raise "tmux is not on PATH" options = [executable: tmux, native_helper: {:embedded, @helper}] pane = Server.with_owned(options, fn server -> Server.new_session!(server, "demo", command: {:argv, ["/bin/cat"]}) server |> Server.snapshot!() |> Snapshot.panes() |> Selection.one!() end) IO.puts(pane.id) end end ``` Build with `MIX_ENV=prod mix escript.build` and copy `escript_pane` to the destination. Run it from any working directory. The target needs `escript` and tmux on `PATH`. Set `TMPDIR` to a trusted writable directory on a filesystem that allows execution if the default does not meet those conditions. The deployed file and its directory can be read-only. [`Server.start/1`]() writes the embedded helper in the private server directory with mode 0700. Commands and control clients on that descriptor use its helper. After the server retires, libtmux removes its directory and helper. An uncertain retirement or abrupt VM exit can leave the directory behind. A successful run prints `%0` after teardown. ## Persistent connection components The internal Guardian owns one native helper and monitors its Manager and router independently. Startup grants one stdout credit after router demand. After activation it keeps one native read in flight and buffers at most 64 KiB or 128 stdout chunks while Router consumes its previous chunk. Each native read and delivered chunk fits 8 KiB. Exceeding either queue ceiling closes the epoch with `resource_limit`; it does not indefinitely stop reading from a still-attached client. These limits do not cap the borrowed tmux server's allocations or total process memory. Guardian caps stderr at 8 KiB and 64 chunks, and acknowledges one write fragment at a time. A fragment fits 8 KiB; a complete rendered command fits 64 KiB. The writer rechecks the consumed publication lease, original deadline and epoch. A partial line keeps its writer until the newline is acknowledged or the epoch closes. Completed slots retain their generation to reject replay. After orderly EOF or native exit, Guardian blocks further writes and drains already-received stdout through the existing Router credits. An end token follows pending native write acknowledgements; Router acknowledges it after processing earlier data and write messages. Only then does ordinary closure finalize remaining operations. Explicit closure, owner loss or protocol failure can abort that drain. Established results survive; unfinished effects remain uncertain. Drain and closure share the original 750 ms Guardian and 800 ms Manager cleanup allowances. Neither clock restarts after data delivery. Helper terminal acknowledgement remains independent of Router progress. Deadline accounting uses one 25 ms timer, rescheduled only after consumption. Busy delivery closes the epoch instead of suspending the owner or retrying. Retirement needs native terminal proof, its acknowledgement and actual helper exit; missing proof or Manager loss leaves the shared lifetime unclean. Supervisor shutdown without those proofs also leaves it unclean. Reserved closure revokes the exact lifetime generation without consuming a command or metadata slot. Guardian observes that word on its accounting timer even when Manager or Router makes no progress. A concurrent starting-to-ready transition cannot escape revocation; retries follow only the same generation. Revocation requests closure and blocks later checks. It does not prove cleanup or prevent a write that already passed its final check. Native and actor retirement remain separate required evidence. Startup uses [`attach-session -E`](https://libtmux.org/en/tmux/latest/manual/attach-session/) to preserve the borrowed session environment. Attachment still changes client counts and session activity. After reading the server PID and Linux process identity, a fresh same-connection challenge must return the exact nonce/PID and receive a complete native write acknowledgement before activation. It shares the original startup deadline. The server and inspected `/proc` must share a PID namespace. This requires host authority for completed, clean configuration throughout the epoch: no aliases overriding admitted command names, no executable effective hooks, and no unqualified messages or subscriptions that can write to the control stream. Other clients can inject multiline text through client-directed messages; parser limits cannot authenticate such output. Absence of a configuration-error notification cannot certify configuration. The library never silently disables hooks or changes configuration. The internal epoch router registers operation identity and FIFO position before sending fragments. A qualified reply after final-fragment dispatch can establish an immutable logical result before the native acknowledgement arrives. The writer still waits for native acknowledgement before advancing; wire retirement also requires it. Completed reply events survive a later parser error in the same chunk. Expired unsent work removes its exact queued token before capacity reuse. The lane admits encoded field reads, literal server user-option writes, split, rename and literal/named input. Option names are bounded ASCII and values do not expand. It rejects arbitrary command lines and screen capture output. Host qualification includes pane-mode key bindings, which can enqueue other commands in response to input. Reply numbers must increase when observed; gaps are normal because other clients and callbacks use the same server counter. This does not detect every possible counter wrap or authenticate an unqualified stream. Metadata requests use a separate fixed ETS inbox before any wake message. Its context binds the real table owner, capacity, allowed request kinds and atomics references. Publication creates the caller's reply alias and token; only a small ready notification enters its mailbox. Owner completion and caller receipt remain separate: a finished row stays occupied until alias closure and receipt acknowledgement, or caller death. A monotone receipt word cannot regress when a delayed old close meets a replacement generation. Wake hints coalesce across slot reuse. Router stores the exact retired record before notifying the waiter Inbox through that same Inbox's single pending wake. Manager consumes the hint before examining the records. Accounting sweeps can service records and both Inboxes while a paused publisher still owns a pending hint. Inbox outcomes copy every binary leaf, including map keys. Copying charges bytes and nodes before allocation, caps depth at 64 and nodes at 8192, and rejects functions, ports and unqualified references. Known context references come from explicitly identified, separately bounded resources. Metadata keeps the default 64 KiB outcome allowance; an independently configured Inbox may reserve 1–128 KiB so a 64 KiB reply plus its envelope fits. The 1 KiB minimum covers fixed fallback errors. Copying shares the original deadline, checked again before result publication. The selected waiter design retains bounded outcome copies in receipt-controlled Inbox rows, superseding the earlier record-reference-only proposal. This avoids cross-table pin/reclamation races at the cost of separately charged copies. The internal waiter owner settles accepted requests from the exact immutable terminal record before releasing it. A prior pending read cannot justify forgetting a later completed record. Closed or expired waiters affect no operation state; pre-acceptance await failures retain unknown effect certainty. Manager services its separate waiter Inbox before reconnect admission and startup continuations, and again after actor events. Both explicit forget and automatic record expiry use the exact-record release barrier. A finished waiter copy survives record reclamation and epoch replacement until receipt. Lost waiter storage closes an active epoch and blocks this Manager's reuse. If native retirement was already proved, that lifetime remains retired; the Manager's fault does not erase cleanup knowledge or preserve lost tables across its replacement. ### Connection accounting Operation, metadata and waiter capacities are independent. Each defaults to 32 and accepts 1–256 slots. Retained operations can occupy their slots across reconnect while the same Manager survives. | Storage | Per-connection accounting | | --- | --- | | Operation admission and records | One lease and one record per operation slot. Charge up to 20,000 bytes for a published request and 64 KiB for its rendered command. Charge the reply observation and logical result separately, each up to 64 KiB of line content with at most 1,024 lines. The sites can share binary backing storage. | | Router and Guardian | At most one Router entry and one Guardian write registration per operation slot, one active writer and one bounded parser frame. Guardian's stdout queue adds up to 64 KiB or 128 chunks, with 8 KiB granted per native read or Router delivery. Stderr retains at most 8 KiB and 64 chunks. | | Metadata and waiter Inboxes | One row per configured slot, up to 3,072 external bytes per request and up to 64 KiB per metadata outcome or 128 KiB per waiter outcome. An outcome copy walks up to 8,192 nodes at depth up to 64. Each Inbox has at most one outstanding wake hint, independent of slot turnover. | | Native helper | An input buffer of 32,768 bytes plus the length prefix, an 8 KiB write buffer and eight output buffers of 8,196 bytes each. Child stdio pipes request 8 KiB apiece. | A Manager waiter turn scans admission and waiter slots and checks active waiters. Reclaiming a retired record can scan the active waiters again to settle and prepare copies for that exact lease. The orphan and expiry passes can do that for each operation slot. A metadata turn scans its Inbox and sorts accepted requests. Each forget can run the same exact-record reclamation. Router parses a credited chunk at a time with up to 128 events per feed and can scan its bounded operation queue during retirement. Turn counts, reductions and elapsed time measure different kinds of work. The table accounts for payloads and fixed buffer sites. Total resident memory also includes data being copied, BEAM and ETS overhead, binary backing storage, Port and kernel pipes, and the attached tmux process. Measure binary backing allocations separately from ETS words and per-process heaps. The borrowed server and copies held by callers have independent lifetimes. Measure them separately when accounting for a workload. ### Managed execution [`Control.execute/3`]() uses the same operation slots and a collection request in the existing waiter Inbox. It waits for wire retirement, detaches the result for every accepted collector, releases the exact operation lease, then makes collector copies readable. Ordinary [`Operation.await/2`]() may still return an acknowledged result before wire retirement. It does not reclaim the record. Expired or closed collectors settle independently. Failure to prepare the remaining bounded result copies preserves the record. Expiry after release can still prevent delivery: [`Control.ExecutionError`]() then reports lost context. No timeout establishes no effects or authorizes replay. Already completed waiter copies stay in their fixed Inbox slots until receipt or caller death. An acknowledged completed row may be reused by a publisher through an exact-generation compare-and-swap, without waiting for a sweep; unfinished work cannot be recycled this way. A managed lease names its original publisher at admission. The Manager keeps at most one monitor per managed lease and reclaims a dead publisher's record only after wire retirement, including death before collection registration. Existing actor events and publisher DOWN signals service this work; no per-command cleanup process is created. Existing unpublished-lease accounting still fences a publication that never arrives before its deadline. After an execution error, a live caller can inspect its retained Operation until forget, expiry or Manager loss. Death of that original caller also permits reclamation, even if it passed the handle elsewhere. Use [`Control.submit/3`]() for retention independent of the submitting process. ### Retained operation records Accounting finalizes retained records for all observed dead destinations in one lease scan, matching each epoch and PID together. It preserves acknowledged results and dispatched uncertainty, and releases no live destination's record. [`LibTmux.Operation`]() pins its original record, lease and Inboxes. Retained status and result reads are local. Each await claims a bounded independent slot and releases its exact alias and monitor on return; timeout does not stop the operation. Metadata admission errors cannot label existing effects as unwritten. Canonical failed, skipped and unknown outcomes remain values, including in bang functions. Forget uses the original lease epoch after reconnect. Stop validates the authoritative Births owner, epoch and Router before revoking its generation through reserved capacity; an already-retired record needs no surviving Births table. Stop closes the whole epoch and may affect siblings. It is a request, never rollback or native retirement proof. The retained-record registry finalizes an epoch only after its exact Router PID has exited. It scans current admission leases, including a consumed lease whose Router died before storing its first record. Router stores its record and writing phase before sending, so an absent matching record proves no write under that ordering. Existing acknowledged results remain intact; dispatched work without evidence remains unknown. These outcomes retain their slots until explicit release. Clearing a released record uses its exact old value, preserving any replacement already published in that slot. Logical finalization does not prove Guardian/helper cleanup or authorize a new epoch; Manager must separately establish complete resource retirement. ### Startup actor registration Startup registration uses one fixed row for three epoch actor roles and its gate. Each actor records its own PID before side effects. Closing the gate captures all accepted PIDs in the same CAS; a queued late startup cannot be omitted between a separate read and close. Router and Guardian bind the supplied registration to their manager, epoch and original deadline. Guardian also rechecks actor aliveness and its starting lifetime before opening the driver. An accepted PID remains owned through actual exit: registration or a pre-open check can race later closure. Gate closure alone is not native retirement. ### Supervisor requests and native retirement Manager keeps one asynchronous request to an ordinary Supervisor outstanding while it accounts for deadlines and metadata. A suspended Supervisor cannot park that accounting. Closing the reply alias does not cancel a queued Supervisor action; an abandoned unresolved start leaves cleanup unknown and blocks replacement. Captured actors remain monitored independently of the request alias. A Router born without a Guardian exits after the startup gate closes. A captured pair binds even during closure, including buffered native retirement events. Explicit reconnect carries its original deadline through old retirement and new bootstrap. Replacement requires native proof, actual Guardian and Router exit, the host's child-finalization acknowledgment and EpochSupervisor exit. Manager restarts preserve the external lifetime latch and do not reconnect automatically. The internal qualified cases retain outcomes across reconnect, forget exact completed leases, and expire retained records. Accepted metadata work remains owned after caller timeout or alias closure; neither cancels it. The internal connection Supervisor owns the view and starts EpochHost before Manager. Its external child-spec factory pins the lifetime across root restarts. Manager replacement invalidates its old tables; root replacement also invalidates the view. A surviving view never recovers old operation evidence. Finite Supervisor shutdown can leave descendants alive; only the shared unknown/unretired lifetime prevents a replacement helper in that case. An unsuccessful descriptor handoff after root startup kills the known root and reports cleanup uncertainty, even after observing root exit. ### OTP supervisor startup The internal startup adapter passes the remaining initialization budget to OTP's generic server entry with its source-qualified Supervisor init shape. OTP stores the adapter as its callback; the adapter delegates the original module and arguments. A private alias captures the exact Root PID before delegation so cleanup drains only that Root's racing startup ACK or NACK. Descriptor publication rechecks the original deadline, and failed handoff cleanup uses only its remaining budget. OTP still waits for actual Root DOWN after an initialization timeout; this primitive alone does not prove a strict caller-return deadline or complete descendant retirement. The adapter is maintained against [OTP 29.1.2 supervisor startup](https://github.com/erlang/otp/blob/d199a49a01a2079afb6f2c5c9ae047cd4555e68d/lib/stdlib/src/supervisor.erl#L547-L548) and [proc_lib timeout cleanup](https://github.com/erlang/otp/blob/d199a49a01a2079afb6f2c5c9ae047cd4555e68d/lib/stdlib/src/proc_lib.erl#L438-L453). The public Supervisor API has no initialization timeout option. The adapter rejects runtime OTP majors other than 29, or a library build made with an Elixir compiled for another OTP major, as `unsupported_runtime` with no-write certainty before Root startup. Build identity is captured at compilation so this check cannot demand-load version parsing during a cold startup. This is a major-version guard, not patch qualification: the support manifest and reference/tracking runtime checks enforce the declared patch minima and verify the running Elixir's compiled OTP identity. Passing the guard alone does not qualify every OTP 29 patch. When updating OTP support, review the pinned Supervisor initialization shape, parent handling and `proc_lib` timeout/ACK cleanup. Run the direct adapter, connection-Supervisor, cold-loader and native startup/ownership checks on the reference and resolved tracking toolchains before changing the guard. Record their actual versions; identical resolutions qualify one toolchain pair. Public [`Supervisor.start_link`]() has no initialization timeout. A temporary `proc_lib` bridge changes the Root's recorded parent; transferring a link does not adopt a new parent. An external watchdog that kills a still-linked Root can kill a non-trapping caller. Replacing the adapter requires a qualified handoff design as well as a timer. The current isolated dependency remains private OTP coupling despite these compatibility checks. The initialization timer belongs to the caller. If that caller dies while the Supervisor callback is blocked, the Root can outlive its original deadline: the Supervisor traps the parent's exit until initialization returns. The adapter does not promise cleanup after untrappable startup-caller death. Both startup wrappers close their private reply aliases through local BIFs and zero-time receives. Timeout cleanup does not demand-load the shared reply helper after Root exit. Isolated loader-gate checks qualify this dependency; they do not bound OTP's actual-DOWN wait or explain earlier timing failures. Failed initial startup fences the fresh lifetime even before its first epoch reservation. If that reservation wins the CAS race, the fence closes only the first generation. Proven retirement remains intact, and later generations cannot be revoked by an old failure. Root cleanup uses its generation captured at startup entry. Manager can remain inert at generation zero with unknown cleanup through normal shutdown or Host loss, without creating epoch actors. This fence handles observed startup failures; it does not establish recovery from untrappable caller or VM death. One lifetime belongs to one connection Root; concurrent starts sharing that lifetime intentionally fail closed. ### Starting a connection and replacing its handle [`Control.start_link/1`]() requires an explicit Server, exact existing session ID and host-qualified lane. It returns `{:ok, root, control}` only after fresh bootstrap and a bounded ready exchange. Its 1..600000ms timeout includes preparation, Root startup and handoff; every successful handoff rechecks the original deadline. The provisional handle stays internal. Accepted ready replies bind their exact endpoint without a later Births or latest-view lookup. If startup failed before ready registration, the error retains the original failure kind. Cleanup fences the lifetime, requests exact-Root termination, and reports actual Root exit only when observed. Native cleanup can remain unknown. Ordinary linked-process exits retain their OTP semantics. [`Control.child_spec/1`]() prepares detached bounded process bytes without I/O. One lifetime survives its permanent factory's invocations. Each invocation starts a new startup budget, but a nonfresh lifetime returns inert instead of automatically attaching. Explicit reconnect requires proven retirement; unknown cleanup, including generation zero, returns a structured error. [`Supervisor.start_child/2`]() and [`Supervisor.restart_child/2`]() return fresh handle info. After automatic restart, terminate and restart that exact child to obtain the new info; this recovery does not clear unknown cleanup. Retain a distinct child spec/lifetime per Root, and never use an old handle as a locator. ### Submitting and closing a connection [`Control.submit/3`]() pins a ready Root view, Manager and epoch. It detaches the request's binary leaves under a separate 20,000-byte owned-term limit before claiming a fixed operation slot. One deadline includes validation, admission, queueing, writing and replies. After claim, pure Operation binding preserves the handle even if context disappears. A final local gate check can suppress publication; the reserved lease stays owned. Its original deadline requests epoch closure; capacity still follows native/destination retirement and record retention or explicit forget rules. Router and Guardian independently validate before writing. [`Control.request_close/1`]() requests whole-epoch closure without claiming a slot, including when operation and metadata capacity are full. It does not acknowledge native retirement or roll back siblings. Repeated requests for the same closing or proven-retired generation succeed; old handles cannot follow replacement Managers or epochs. Status errors report unknown certainty about existing work; a rejected new, unadmitted submission reports no write. [`Control.close/2`]() waits for native and epoch-actor retirement plus the Host's epoch-child finalization acknowledgement under its original budget. An admitted metadata watcher retains its fixed Inbox cell through settlement, including after caller closure. Metadata settlement failure blocks replacement. Ready watches never start a failed or closed epoch. Accepted retirement watches settle before reconnect in the same batch, independent of slot order. Epoch reservation rechecks metadata and waiter storage; lost storage cannot authorize replacement. [`Control.reconnect/2`]() returns the acknowledged endpoint directly. A delayed caller receives that epoch even if a newer one already exists; its handle then reports stale. It does not reread the latest view or replay operations. The Root and retained records outlive ordinary epoch closure. Public lifecycle errors preserve unknown certainty about existing effects; direct retirement proof must still be observed within the original close budget. Strict caller-return startup bounds, connection-wide accounting and authoritative subscriptions remain unqualified. These component checks do not qualify those contracts. --- # Command and field encoding Source: https://libtmux.org/en/elixir/pr-173/topics/encoding/ > Render commands and decode fields without a shell or a raw newline. [`LibTmux.Command`]() is a value. Constructing it or rendering its bytes performs no I/O. Both one-shot execution and the qualified persistent control lane use these encoders. ## Separate parsers [`Command.argv/2`]() returns process arguments and protects terminal semicolons from tmux's argument-vector parser. It does not invoke a shell. [`Command.render/2`]() produces one tmux command line with every argument byte octal-escaped inside double quotes. The result contains no raw newline or carriage return. It excludes the framing newline the control writer adds. Both renderers validate the encoded byte budget before dispatch. Command quoting does not protect a value that a command interprets as a tmux format. [`LibTmux.Format.literal/1`]() constructs a literal format operand without evaluating embedded `#{...}`, shell jobs or shorthand variables. It accepts non-NUL bytes. The command still needs its own appropriate format flags; arbitrary commands have different expansion behavior. ## One field per response [`Format.field/1`]() encodes a named field with a `v1:` marker. It replaces backslashes first, then dollars and ASCII control bytes, using fixed tmux substitutions. [`LibTmux.Codec.decode_field/3`]() with `encoding: :escaped_v1` requires that marker, removes one framing newline and decodes escapes once. The conservative field format performs several substitutions. This encoding avoids an ambiguity in tmux 3.4: its command print path escapes some bytes while preserving literal backslashes. Removing arbitrary backslashes from that output would corrupt legitimate values. A versioned field encoding protects those values before printing. A separator byte alone cannot do that, because titles and paths may contain it. The default raw decoder removes only the final framing newline. Its source must independently guarantee unmodified bytes. It must not be applied to an unqualified tmux print path. Text decoding requires UTF-8; `:bytes` retains arbitrary bytes. Integer parsing consumes the whole value and can enforce a range; Boolean parsing accepts only `0` or `1`. ## Capture rows Snapshot capture reads free-form fields with one listing each for sessions, windows and panes. Each row starts with `r1:N`, followed by N tab-separated `v1:` fields and one final newline. The first field identifies the entity. Each field uses the conservative encoder above: tabs and newlines inside values become escapes, so they cannot become row delimiters. The decoder checks the version, field count and schema. Invalid UTF-8 remains an error for text fields. Missing identities or conflicting linked rows trigger the existing finite reconciliation retry. The default response ceiling is 64 KiB, including markers and separators. After a pane listing exceeds it and its client has retired, capture divides the pane IDs into smaller ranges and reads each range with the same row format. Each range must return the expected IDs. An oversized range can split again, down to an individual pane read. Session and window overflow use individual reads directly. An individual response carries the text fields only and still has to fit. Timeout, decoding, stderr-limit and unclear cleanup failures end the read without triggering this fallback. A successful attempt uses 13 commands when all three text listings fit. Fallback adds commands for each narrower listing and each individual read. Every command launches one owned helper and one tmux client. Linked text rows can repeat in a listing; identical values are deduplicated after decoding. Both topology scans count contextual rows against `max_entities`. Text responses are bounded by the command and byte budgets. All reads, including an overflowing listing, consume the same command, byte and deadline budgets. Tightly sized budgets may run out during narrower listings, especially if linked text repeats or many rows are large. Reuse a snapshot for several local queries and capture again when fresh state is needed. This encoding does not qualify arbitrary pane output or hook output for a shared control lane. ## Bounded framing [`LibTmux.Protocol`]() is a pure control-mode parser with separate chunk, line, frame, line-count and emitted-event ceilings. It retains reply guard IDs; notification-looking lines inside a reply remain output. A rejected suffix preserves completed prefix events in the structured error. Retire a lane after a parse error. Lexical parsing cannot authenticate output that forges a matching guard. Commands, aliases, hooks and subscriptions require separate admission rules before sharing a persistent lane. Parser ceilings also do not bound upstream Port delivery or a connection owner's mailbox. Those transport contracts require independent qualification. --- # Observation and filter schema Source: https://libtmux.org/en/elixir/pr-173/topics/schema/ > Fields, wire names, value categories and operators of each observed entity. Generated from [`LibTmux.Schema`](); regenerate with `mix run scripts/generate_schema.exs`. All current fields use the tmux 3.3 capture baseline. Coverage must still be loaded. Only `nullable_integer` admits [`nil`](); other unavailable or unloaded fields raise. Link IDs are `{session_id, index, window_id}` locally and three-element arrays on the wire. See [filtering](https://libtmux.org/en/elixir/pr-173/guides/filtering/) for Boolean, relation and error semantics. ## `session` | Elixir field | Wire field | Value category | tmux format | Operators | | --- | --- | --- | --- | --- | | [`attached`]() | [`attached`]() | `:boolean` | Derived | `equals`, `not`, `in`, `not_in` | | [`attached_count`]() | `attachedCount` | `:integer` | [`session_attached`](https://libtmux.org/en/tmux/latest/catalog/formats/session_attached/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`id`]() | [`id`]() | `{:id, :session}` | [`session_id`](https://libtmux.org/en/tmux/latest/catalog/formats/session_id/) | `equals`, `not`, `in`, `not_in` | | `name` | `name` | `:string` | [`session_name`](https://libtmux.org/en/tmux/latest/catalog/formats/session_name/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | Relation | Wire relation | Cardinality | Target | Operators | | --- | --- | --- | --- | --- | | [`active_window`]() | `activeWindow` | [`one`]() | `window` | `is`, `is_not` | | `clients` | `clients` | `many` | `client` | `some`, `every`, [`none`](), [`count`]() | | `panes` | `panes` | `many` | `pane` | `some`, `every`, [`none`](), [`count`]() | | `window_links` | `windowLinks` | `many` | `window_link` | `some`, `every`, [`none`](), [`count`]() | | `windows` | `windows` | `many` | `window` | `some`, `every`, [`none`](), [`count`]() | ## `window` | Elixir field | Wire field | Value category | tmux format | Operators | | --- | --- | --- | --- | --- | | `height` | `height` | `:integer` | [`window_height`](https://libtmux.org/en/tmux/latest/catalog/formats/window_height/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`id`]() | [`id`]() | `{:id, :window}` | [`window_id`](https://libtmux.org/en/tmux/latest/catalog/formats/window_id/) | `equals`, `not`, `in`, `not_in` | | [`layout`]() | [`layout`]() | `:string` | [`window_layout`](https://libtmux.org/en/tmux/latest/catalog/formats/window_layout/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | `name` | `name` | `:string` | [`window_name`](https://libtmux.org/en/tmux/latest/catalog/formats/window_name/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | `width` | `width` | `:integer` | [`window_width`](https://libtmux.org/en/tmux/latest/catalog/formats/window_width/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`zoomed`]() | [`zoomed`]() | `:boolean` | [`window_zoomed_flag`](https://libtmux.org/en/tmux/latest/catalog/formats/window_zoomed_flag/) | `equals`, `not`, `in`, `not_in` | | Relation | Wire relation | Cardinality | Target | Operators | | --- | --- | --- | --- | --- | | `panes` | `panes` | `many` | `pane` | `some`, `every`, [`none`](), [`count`]() | | `sessions` | `sessions` | `many` | `session` | `some`, `every`, [`none`](), [`count`]() | | `window_links` | `windowLinks` | `many` | `window_link` | `some`, `every`, [`none`](), [`count`]() | ## `window_link` | Elixir field | Wire field | Value category | tmux format | Operators | | --- | --- | --- | --- | --- | | `active` | `active` | `:boolean` | [`window_active`](https://libtmux.org/en/tmux/latest/catalog/formats/window_active/) | `equals`, `not`, `in`, `not_in` | | [`id`]() | [`id`]() | `{:id, :window_link}` | Derived | `equals`, `not`, `in`, `not_in` | | `index` | `index` | `:integer` | [`window_index`](https://libtmux.org/en/tmux/latest/catalog/formats/window_index/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`session_id`](https://libtmux.org/en/tmux/latest/catalog/formats/session_id/) | `sessionId` | `{:id, :session}` | [`session_id`](https://libtmux.org/en/tmux/latest/catalog/formats/session_id/) | `equals`, `not`, `in`, `not_in` | | [`window_id`](https://libtmux.org/en/tmux/latest/catalog/formats/window_id/) | `windowId` | `{:id, :window}` | [`window_id`](https://libtmux.org/en/tmux/latest/catalog/formats/window_id/) | `equals`, `not`, `in`, `not_in` | | Relation | Wire relation | Cardinality | Target | Operators | | --- | --- | --- | --- | --- | | `session` | `session` | [`one`]() | `session` | `is`, `is_not` | | `window` | `window` | [`one`]() | `window` | `is`, `is_not` | ## `pane` | Elixir field | Wire field | Value category | tmux format | Operators | | --- | --- | --- | --- | --- | | `active` | `active` | `:boolean` | [`pane_active`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_active/) | `equals`, `not`, `in`, `not_in` | | [`current_command`]() | `currentCommand` | `:string` | [`pane_current_command`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_current_command/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | [`current_path`]() | `currentPath` | `:string` | [`pane_current_path`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_current_path/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | [`dead`]() | [`dead`]() | `:boolean` | [`pane_dead`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_dead/) | `equals`, `not`, `in`, `not_in` | | [`exit_status`]() | `exitStatus` | `:nullable_integer` | [`pane_dead_status`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_dead_status/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | `height` | `height` | `:integer` | [`pane_height`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_height/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`id`]() | [`id`]() | `{:id, :pane}` | [`pane_id`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_id/) | `equals`, `not`, `in`, `not_in` | | `index` | `index` | `:integer` | [`pane_index`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_index/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`pid`]() | [`pid`]() | `:nullable_integer` | [`pane_pid`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_pid/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`title`]() | [`title`]() | `:string` | [`pane_title`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_title/) | `equals`, `not`, `in`, `not_in`, `contains`, `starts_with`, `ends_with` | | `width` | `width` | `:integer` | [`pane_width`](https://libtmux.org/en/tmux/latest/catalog/formats/pane_width/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`window_id`](https://libtmux.org/en/tmux/latest/catalog/formats/window_id/) | `windowId` | `{:id, :window}` | [`window_id`](https://libtmux.org/en/tmux/latest/catalog/formats/window_id/) | `equals`, `not`, `in`, `not_in` | | Relation | Wire relation | Cardinality | Target | Operators | | --- | --- | --- | --- | --- | | `window` | `window` | [`one`]() | `window` | `is`, `is_not` | ## `client` | Elixir field | Wire field | Value category | tmux format | Operators | | --- | --- | --- | --- | --- | | [`control_mode`]() | `controlMode` | `:boolean` | [`client_control_mode`](https://libtmux.org/en/tmux/latest/catalog/formats/client_control_mode/) | `equals`, `not`, `in`, `not_in` | | `height` | `height` | `:nullable_integer` | [`client_height`](https://libtmux.org/en/tmux/latest/catalog/formats/client_height/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`id`]() | [`id`]() | `{:id, :client}` | [`client_name`](https://libtmux.org/en/tmux/latest/catalog/formats/client_name/) | `equals`, `not`, `in`, `not_in` | | [`pid`]() | [`pid`]() | `:integer` | [`client_pid`](https://libtmux.org/en/tmux/latest/catalog/formats/client_pid/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | [`session_id`](https://libtmux.org/en/tmux/latest/catalog/formats/session_id/) | `sessionId` | `{:id, :session}` | [`session_id`](https://libtmux.org/en/tmux/latest/catalog/formats/session_id/) | `equals`, `not`, `in`, `not_in` | | `width` | `width` | `:integer` | [`client_width`](https://libtmux.org/en/tmux/latest/catalog/formats/client_width/) | `equals`, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte` | | Relation | Wire relation | Cardinality | Target | Operators | | --- | --- | --- | --- | --- | | `session` | `session` | [`one`]() | `session` | `is`, `is_not` |