Server
Describes a local tmux server for capturing state and running commands.
Source and package
- Qualified name
-
LibTmux. Server - Module
- LibTmux
- Package
- libtmux
- Source
- lib/libtmux/server.ex
-
Description
new/1takes an absolute:executablepath. UseSystem.find_executable/1to resolve a name such as"tmux"through PATH before construction. The optional:cwdand:envdefault to the caller's working directory and environment. Construction validates the path forms without checking that the executable or socket exists. A Server is an immutable value; constructing one withnew/1neither connects to tmux nor starts it. Commands use-N, so a missing daemon is never started implicitly.start/1andwith_owned/2start a private server and return a Server thatstop/2can retire.Choosing the server
new/1picks the socket in this order, and the first rule that applies wins:-
:socket, an absolute socket path, passes-S. -
:socket_name, a socket name, passes-L. Pass at most one of:socketand:socket_name. - The
LIBTMUX_SOCKET_PATHvariable passes-Swith its path. - The
LIBTMUX_SOCKETvariable passes-Lwith its name. - Otherwise no socket is passed, and tmux chooses. It follows the server that
TMUXnames when:envhas one, and otherwise uses its default socket:defaultin thetmux-UIDdirectory ofTMUX_TMPDIR, or of/tmp.
An explicit option ignores both variables, even an invalid one. When both variables are set, the path wins, as
-Sdoes over-Lin tmux. A variable that is empty counts as unset, each one alone. The variables come from the:envoption, which defaults to the caller's environment, so a Server built with its own:envignores the caller's variables. A set variable with an invalid value raisesArgumentErrorthat names the variable and never repeats its value.The choice is made once, in
new/1, andt:t/0records it. A Server that chose a socket removesTMUXandTMUX_PANEfrom the environment it gives tmux, so a surrounding tmux session cannot redirect it. A Server that chose none keeps both, for one-shot execution and for control connections alike, so a program run inside tmux reaches the server it runs in. LeaveTMUXout of:envto send a Server with no socket to tmux's default socket instead.What is on here
Server describes the endpoint. In Elixir, observation, selection and action functions live in their own modules. Start with these groups:
- Connecting
- Describe the server for one-shot commands, which do not attach a client. Attach a control client to an existing session for the length of a callback; the client closes afterwards. Run a control client under application supervision. See the managed control guide for connection setup and the host's hook and command-alias requirements.
- DescribeAttach for a callback
- Owning a private server
- Start a tmux server in a private directory, with no inherited
TMUXorTMUX_PANE, and stop it when you are done.with_owned/2does both around a function, so a program needs no shell step to start or clean up tmux. The process that starts the server owns it, and the server stops when that process exits.stop/2refuses a Server thatstart/1did not create;kill/2sendskill-serverto any Server. - Start and stop around a functionStartStopKill any serverRaise on failure
- Finding one thing
- Capture a snapshot, then require one match or allow no match. Both reject multiple matches. Turn the chosen observation into a reference tied to the daemon that supplied it, ready for an action.
- CaptureRequire oneAllow noneReference
- Listing everything
- Capture sessions, physical windows, window links, panes and attached clients as a
LibTmux.Snapshot. One accessor per kind returns a selection from that captured graph without contacting tmux again. Capture failures return an error, not an empty server. Capture covers an interval rather than an atomic transaction; take another snapshot when fresh state is needed. - Capture
- Querying things and getting around
- Select by criteria such as
active: true, or by an Elixir function; selections work withEnumandStream. Navigation functions use the supplied snapshot. Plural helpers return selections for further filtering; aLibTmux.WindowLinkpreserves a window's membership in one session. - By criteriaBy functionFocusedOther relationships
- Changing things
- Create detached sessions and windows on an existing server using one-shot execution. Each returns the created ID with
ref: nil; capture a fresh observation to obtain a reference. Split a pane to create a pane and get its ID in the completed result. A qualified Control connection also supplies a bound reference; one-shot split returnsref: nil. Rename a session or a window. Send literal bytes or named keys such as"Enter"to a pane. Split, rename and input take a Server or Control connection followed by a reference. Domain bang variants return completed values or raise; nonbang variants return{:ok, result}for completed commands and{:error, error}otherwise. See the action guide and recovery guide. - SplitSend literal bytesSend named keys
- Reading screens, options and formats
- Capture pane screen bytes through one-shot execution, which requires a Server. On a control connection, execute a request that reads a field or writes a server user option. Submit the request and keep the returned
LibTmux.Operationwhen the result needs to remain available for independent inspection. - ScreenExecuteRead a fieldWrite a user optionSubmit
- Running any other command
- Build a command to run any other tmux command. Running executes one command with literal arguments and returns bounded output and exit evidence. Configured server hooks can still run. Targeted one-shot actions check the observed server identity before writing, leaving a race if the daemon is replaced between that check and the command. Use a qualified Control connection for mutations bound to one daemon instance.
- Build
LibTmux.Command.new/2
Build an identity probe or literal replyRun
-
Members24 members
Collections and queries1
- snapshot/2 function Captures a new graph explicitly, with bounded work and read retries.
Common operations7
- run/3 function Runs one trusted command without attaching; returns bounded output and exit evidence.
- new/1 function Constructs a descriptor for an existing server without connecting or creating it.
- start/1 function Starts a private tmux server and returns a Server for it.
- new_session!/3 function Returns the created session value when
new_session/3completes; raises the original error otherwise. - snapshot_with_diagnostics/2 function Captures a graph and returns work diagnostics on success or failure.
- snapshot!/2 function Captures a graph or raises the same structured capture error.
- with_owned/2 function Starts a private server, calls
funwith it and stops it afterwards.
Other members16
- capabilities/2 function Observes named native tmux prerequisites without attaching or creating resources.
- cwd: String
.t () property Required: building the struct without this key is an error. - daemon: pid() | nil property
- env: %{optional(binary()) => binary()} property Required: building the struct without this key is an error.
- executable: String
.t () property Required: building the struct without this key is an error. - kill!/2 function Returns
:okwhenkill/2completes; raises API errors orLibTmux.Action.CompletionErrorotherwise. - kill/2 function Kills the server with
kill-server, whoever started it. - native_helper: Path
.t () | nil property - new_session/3 function Creates a named detached session on an existing server through one-shot execution.
- option/0: option() ::
{:executable
| :socket
| :socket_name
| :cwd
| :native_helper, String
.t ()} | {:env, %{optional(binary()) => binary()}} typealias Descriptor inputs. - probe_command/1 function Builds a command that prints the daemon's identity or a literal reply.
- socket: String
.t () | nil property - socket_name: String
.t () | nil property - start_option/0: start
_option () :: {:executable, String.t ()} | {:root, String.t ()} | {:config_file, String.t ()} | {:env, %{optional(binary()) => binary()}} | {:native_helper, Path.t () | {:embedded, binary()}} | {:timeout, 1..600_000} typealias Inputs forstart/1. - stop/2 function Stops a server that
start/1created and removes its directory. - t/0: t() :: %Lib
Tmux { cwd: String.Server .t (), daemon: pid() | nil, env: %{optional(binary()) => binary()}, executable: String.t (), native_helper: Path.t () | nil, socket: String.t () | nil, socket_name: String.t () | nil } typealias A local server descriptor; constructing it neither connects nor reserves server identity.
No members of Server match . The filter searches only this type. Search the whole API.
Order: the accessors that walk the hierarchy, the operations the ports share, then the rest.
Guides
task materialPages that discuss Server.
- Concepts
- Guides
In other ports
task equivalence 22 other ports mappedSource-verified mappings for A tmux server. A mapping says these APIs perform the same task. It does not say they share defaults, errors or completion: check each page.
| Port | API | Differs from Elixir |
|---|---|---|
| Elixir | Lib Describes a local tmux server for capturing state and running commands. | This page |
| Python | libtmux tmux(1) Server [server_manual]. | None recorded in the model |
| Ruby | Lib Connects to an existing endpoint. Closing retires clients, never the daemon. | None recorded in the model |
| Lua | libtmux | None recorded in the model |
| PowerShell | Lib Construct a tmux endpoint handle without contacting it. | 2 overloads This cmdlet constructs a shared .NET LibTmux.Server handle without contacting tmux. |
| Julia | Lib Describe a tmux endpoint without contacting it. Supply exactly one socket selector. A description does not own a daemon or any sessions. Use from_env to opt into the ambient tmux endpoint. | |
| Erlang | tmux Open tmux endpoints and execute explicit command values. | open/1 observes an existing daemon and starts an endpoint owner. Domain rows remain immutable values. |
| Haskell | Lib Start, observe and change a tmux daemon through a scoped handle. | LibTmux.Server owns the Server handle. withOwnedServer starts and retires a private daemon; withServer borrows an existing endpoint and releases its own resources afterwards. killServer retires the admitted daemon generation explicitly. Operations such as capture and renameSession are functions of this module that take the handle. |
| Common Lisp | libtmux: A connection scope with one external-operation lease.
Closing cancels owned work and leaves the tmux daemon alive. Captured data may
outlive the client. Public operations never expose its mutable storage. | |
| TypeScript | server One tmux server, addressed by the socket it listens on. | None recorded in the model |
| Rust | server A cloneable handle to one captured tmux server endpoint. | None recorded in the model |
| Go | tmux Server is an immutable handle to one tmux configuration. Its zero value is invalid. Copying a configured Server preserves its configuration and shares its mutex-guarded version cache and checked daemon identity, so a Server and the values derived from it are safe for concurrent method calls (see the package documentation). | None recorded in the model |
| Java | io Manages sessions, windows, and panes on a tmux server. | readonly |
| Clojure | libtmux Opens local resources for an explicit :socket-path or :socket-name endpoint. | Opens a closeable Java server client for an explicit endpoint. Acquisitions return persistent maps with explicit Java references for effects. |
| Kotlin | io Manages sessions, windows, and panes on a tmux server. | None recorded in the model |
| Scala | io The Java client, opaque: every member beyond java.lang.AutoCloseable#close is an extension, generated from the operation catalog or handwritten where the catalog marks it WAIT, STREAM or LIFECYCLE. Closing an owned client releases its transport, not tmux; close() comes from the AutoCloseable bound with no forwarding of its own, so Using.resource(server) { ... } works. | 2 overloads |
| C# | Lib Represents an immutable server handle and snapshot. | None recorded in the model |
| F# | Lib Starts server reads and queries with the caller's cancellation token. | This F# module provides functions over the shared .NET LibTmux.Server type. |
| C++ | libtmux:: One tmux server, addressed by the socket it listens on. | None recorded in the model |
| Swift | Server A tmux server, addressed by its endpoint. | None recorded in the model |
| OCaml | Libtmux An explicit generation-bound connection. Applications retain ownership of the endpoint choice and resource lifetime. | A client is a live, generation-bound server connection. Endpoint describes a socket without connecting; closing a client releases its resources. |
| Perl | Lib Explicit tmux acquisition and commands | Construction records connection settings without tmux I/O. Optional LibTmux::Async::Server returns standard Future results for operations. |
| Raku | Lib | None recorded in the model |