Server
Describes a local tmux server for capturing state and running commands.
Source and package
-
Description#
new/1takes an absolute:executablepath and an absolute:socketpath, which selects tmux's socket file with-S. 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 with nothing to close; constructing one neither connects to tmux nor starts it. Commands use-N, so a missing daemon is never started implicitly.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.
new/1describes the server for one-shot commands, which do not attach a client.LibTmux.Control.with_connection/2attaches a control client to an existing session for a callback and closes it afterwards.LibTmux.Control.start_link/1andLibTmux.Control.child_spec/1support application supervision. See the managed control guide for connection setup and the host's hook and command-alias requirements.Finding one thing. Capture with
snapshot/2, then useLibTmux.Selection.one/2to require one match orLibTmux.Selection.one_or_nil/2to allow no match. Both reject multiple matches.LibTmux.Ref.from_observation/1turns the chosen observation into a reference tied to the daemon that supplied it, ready for an action.Listing everything.
snapshot/2captures aLibTmux.Snapshotcontaining sessions, physical windows, window links, panes and attached clients.LibTmux.Snapshot.sessions/1,LibTmux.Snapshot.windows/1,LibTmux.Snapshot.window_links/1,LibTmux.Snapshot.panes/1andLibTmux.Snapshot.clients/1return selections 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.Querying things and getting around.
LibTmux.Selection.where/2accepts criteria such asactive: true;LibTmux.Selection.filter/2accepts an Elixir function. Selections work withEnumandStream. Navigate the captured graph withLibTmux.Session.windows/2,LibTmux.Session.panes/2,LibTmux.Session.active_window/2andLibTmux.Window.panes/2, or useLibTmux.Snapshot.related/4for other relationships. These functions use the supplied snapshot. Plural relationship helpers return lists; aLibTmux.WindowLinkpreserves a window's membership in one session.Changing things.
LibTmux.Pane.split/3creates a pane and returns its ID and bound reference in the completed result.LibTmux.Session.rename/4andLibTmux.Window.rename/4change names.LibTmux.Pane.send_text/4sends literal bytes, whileLibTmux.Pane.send_keys/4sends named keys such as"Enter". These functions take a Server or Control connection followed by a reference. Domain bang variants return completed values or raise; nonbang variants return outcomes to inspect. See the action guide and recovery guide.Reading screens, options and formats.
LibTmux.Pane.capture/3reads pane screen bytes through one-shot execution, including when given a Control connection. On a control connection,LibTmux.Control.execute/3runsLibTmux.Control.Request.field/2reads andLibTmux.Control.Request.set_user_option/2server user-option writes. UseLibTmux.Control.submit/3andLibTmux.Operationwhen the result needs to remain available for independent inspection.Other tmux commands are available through
LibTmux.Command.new/2andrun/3, which runs one command with literal arguments and returns bounded output and exit evidence. Configured server hooks can still run. 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.Discussed in Read values, execute explicitly · Getting started
In other ports A tmux server
- PowerShell
LibTmux\New-TmuxServerThis cmdlet constructs a shared .NET
LibTmux.Serverhandle without contacting tmux. - Julia
LibTmux.ServerServerdescribes an endpoint without contacting tmux. Read its hierarchy withsnapshot. - Python
- Ruby
- Lua
- TypeScript
- Rust
- Go
- Java
- C#
- C++
- Swift
- Kotlin
- Scala
- F#
LibTmux.FSharp.ServerThis F# module provides functions over the shared .NET
LibTmux.Servertype.
- PowerShell
Members10#
Collections and queries1#
- snapshot/2 function Captures a new graph explicitly, with bounded work and read retries.
Common operations3#
- 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.
- snapshot!/2 function Captures a graph or raises the same structured capture error.
Other members6#
- cwd: String
.t () property Required: building the struct without this key is an error. - 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. - option/0: option() ::
{:executable | :socket | :cwd, String
.t ()} | {:env, %{optional(binary()) => binary()}} typealias Descriptor inputs; executable, socket and cwd are absolute NUL-free paths. - socket: String
.t () property Required: building the struct without this key is an error. - t/0: t() :: %Lib
Tmux { cwd: String.Server .t (), env: %{optional(binary()) => binary()}, executable: String.t (), socket: String.t () } typealias An explicit local server descriptor; constructing it neither connects nor reserves server identity.