Core Library0.xAPI Reference

Choose documentation 1

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

class libtmux-raku latest

LibTmux.Server

Source and package
Qualified name
LibTmux::Server
Declared in
LibTmux
Package
LibTmux
Source
lib/LibTmux/Server.rakumod
Other languages
Perlclass Erlangmodule PowerShellcmdlet Juliastruct Elixirstruct Haskellmodule Common Lispclass PythonRubyLuaTypeScriptRustGoJavaC#C++SwiftKotlinScalaOCamltypealias F#module Clojurefunction
Anonymous class

Description#

Server ownership

new captures a borrowed endpoint without I/O. snapshot and capabilities acquire daemon state explicitly. new-session requires an existing daemon, creates a detached session, and returns a SessionRef from tmux's returned ID. Names are literal Unicode text; controls, backslash, dot and colon are refused before creation because supported tmux releases normalize them differently. A shell-command explicitly requests tmux's shell-command interpretation.

start creates a clean foreground daemon on an exclusive temporary socket, verifies its executable profile before launch, binds its actual process identity, and creates the initial session. The startup timeout covers all stages. Linux inotify socket attributes signal listener readiness; pidfds bind termination to the original process, independently of socket reuse.

Close is idempotent and joins owned work. Borrowed daemons remain running. Owned daemons receive TERM followed by bounded KILL escalation and are reaped. Cleanup removes only the original socket and empty original directory; unknown files and replacement sockets are preserved. References retain values only and are not clients owned by the Server. A stopped owned daemon invalidates them.

Configuration factories perform one explicit identity observation. The returned facades retain endpoint and incarnation values, and each subsequent configuration operation owns its temporary command client. open-control and attach return separate lifecycle owners: callers must close them. Closing a borrowed Server does not close those owners; closing an owned daemon causes its attached clients to disconnect. attach proves process creation, not terminal readiness.

command is an explicit tmux-syntax escape hatch with a daemon fence. It does not insert an entity target or interpret shell syntax on the caller's behalf. run-batch reports partial outcomes and never promises rollback.

Explicit environment and health

from-env is the only factory that interprets TMUX. It parses its final PID and session components from the right, so commas in the socket path remain literal. It requires an absolute socket path, validates TMUX_PANE when present, observes the actual daemon and rejects a different PID. The returned borrowed facade is bound to that incarnation. Child processes still receive neither ambient variable. Imported object IDs are observations from the supplied environment, not evidence that those objects still exist:

use LibTmux; my $server = LibTmux::Server.from-env(:environment(%*ENV)); LEAVE $server.close; my $snapshot = $server.snapshot; my $pane = $snapshot.panes.where(%(id => $server.environment-pane-id)).single; my $window = $pane.window; my $session = $snapshot.sessions .where(%(id => $server.environment-session-id)).single;

The selection throws for a vanished object or absent imported ID. A window can belong to several sessions; the imported session ID supplies that context. capabilities is the explicit native health observation: success returns verified daemon evidence, while connection, identity and permission failures retain their original typed exceptions. has-session(:name) and has-session(:id) return false only after a successful exact listing finds no match. kill-server deliberately terminates the observed daemon, including a borrowed one; close continues to preserve borrowed daemons. An owner must still close after kill-server to join its process and filesystem cleanup.

Jobs and channels

run-shell receives literal shell source; tmux FORMAT-looking text is escaped before dispatch. if-shell follows the same rule for its shell condition and accepts bounded Invocation values for both branches. Its explicit :format option instead evaluates a native tmux FORMAT condition. source-file reads one literal pathname, escaping native glob metacharacters; it does not expand FORMAT, tilde or a caller shell. Relative paths use the captured command cwd. :parse-only parses configuration without executing it.

Each request shares one admission, observation and dispatch deadline. A background job acknowledges scheduling. Foreground completion follows tmux's job/command queue contract, not an application-specific postcondition; command output availability also depends on the declared daemon profile. Timing out or cancelling a client does not undo a job, configuration effect or channel lock already accepted by the daemon. wait-for offers only wait, signal, lock and unlock; it does not claim that a signal proves another process's application work completed.

Administrative commands

Diagnostics and administrative commands intentionally use the explicit bounded Invocation surface rather than separate wrappers. These complete calls retain raw stdout/stderr in Result, enforce the server deadline and throw typed command errors. list-commands, show-messages, lock-server and server-access are deliberate replacements for named Python helpers, not claims of identical typed parameters. switch-mode is also available through Invocation.

use LibTmux; my $server = LibTmux::Server.start(:name<inspection>); LEAVE $server.close; my $commands = $server.command(Invocation.new(:argv(['list-commands']))); my $access = $server.command(Invocation.new(:argv(['server-access', '-l']))); my $messages = $server.command(Invocation.new(:argv(['show-messages', '-T']))); $server.command(Invocation.new(:argv(['lock-server'])));

Administrative flags keep tmux's native semantics and errors; arbitrary Invocation values do not acquire a typed catalogue guarantee. Locking may run configured lock commands on attached clients. Access changes affect other users. Use only an endpoint whose administration the caller owns or has authorized. To detach captured clients, iterate $snapshot.clients and call each .ref.detach. Each target is identity guarded; a changing client set is not an atomic detach-all operation, and acknowledgement does not prove terminal rendering or child-process exit.

Members46#

Collections and queries2#

  • buffers method Observe daemon identity and return its named binary-buffer facade.
  • snapshot method Acquire a captured graph explicitly. Existing snapshots remain unchanged.

Common operations13#

  • new-session method Create a detached session and return its value-only, identity-scoped reference.
  • kill-server method Explicitly terminate this observed daemon. Owned callers must still close to join cleanup.
  • source-file method Source one literal local pathname; parse-only validates without running its commands.
  • command method Execute explicit tmux command syntax in the currently observed daemon.
  • wait-for method Wait, signal, lock or unlock a named channel; timeout cannot undo server-side effects.
  • run-shell method Run literal shell source through tmux. Background acknowledgement is not job completion.
  • has-session method Test one exact session ID or name. Acquisition and identity failures still throw.
  • capabilities method Observe the daemon's capabilities explicitly; this performs tmux I/O.
  • attach method Spawn a separately owned interactive client on the caller's explicit terminal.
  • start method Start an owned foreground daemon on a fresh private socket and create its first session.
  • if-shell method Execute one of two bounded commands after a shell test, or an explicit FORMAT condition.
  • run-batch method Run a declared batch with one observed incarnation and a shared deadline.
  • from-env method Import an explicit TMUX environment, verify its daemon PID and bind that incarnation.

Other members31#

  • attach-async method Resolve a separately owned terminal client; process creation is not attachment proof.
  • capabilities-async method Resolve to one fresh immutable daemon capability observation.
  • clone method Refuse cloning of runtime admission and daemon ownership state.
  • close method Join idempotent shutdown; borrowed daemons remain running.
  • close-async method Join admitted work; owned servers additionally terminate and reap their original daemon.
  • command-async method Copy input before scheduling one guarded command; retain exit status and raw streams.
  • endpoint: Endpoint:D property Captured connection settings; retaining them owns no process.
  • environment method Observe daemon identity and return its global environment facade.
  • environment-pane-id: PaneId property Pane ID explicitly imported from TMUX_PANE; undefined for ordinary construction.
  • environment-session-id: SessionId property Session ID explicitly imported from TMUX; undefined when tmux supplied -1.
  • explain method Observe capabilities and explain an explicit source query without executing its listing.
  • explain-panes method Explain pane acquisition, pushed restrictions and residual local work.
  • hooks method Observe daemon identity and return global session/window hooks.
  • key-bindings method Observe daemon identity and return its key-binding facade.
  • max-command-bytes: Positive:D property Maximum encoded command size in bytes, including tmux quoting.
  • max-output-bytes: Positive:D property Combined output-byte limit for one owned command response.
  • new method Capture a borrowed endpoint without I/O. Closing it closes clients only.
  • open-control method Open a separately owned control connection attached to an explicit session ID.
  • open-control-async method Resolve a separately owned verified control connection; the caller must close it.
  • options method Observe daemon identity and return server options or global session/window defaults.
  • owned method Whether this facade owns the foreground daemon it started.
  • query method Acquire a typed selection; only requested relationship predicates load the full graph.
  • query-async method Copy and validate query data before scheduling acquisition within one shared deadline.
  • query-panes method Acquire panes explicitly; the resulting selection is local and replayable.
  • query-sessions method Acquire sessions explicitly under the selected pushdown policy.
  • query-window-links method Acquire session/index associations without deduplicating repeated window placements.
  • query-windows method Acquire unique physical windows, preserving link context separately.
  • run-batch-async method Resolve per-operation outcomes with one deadline spanning observation and dispatch.
  • run-shell-async method Resolve the bounded tmux job request; cancellation does not undo a server-side job.
  • snapshot-async method Resolve a fresh captured graph; cancellation propagates through every acquisition stage.
  • wait-for-async method Resolve one channel operation within the Server deadline, without readiness polling.

In other ports#

A tmux server

Equivalents of A tmux server in other languages
Language Equivalent
Python libtmux.Server
Ruby LibTmux::Server
Lua libtmux.Server
PowerShell LibTmux\New-TmuxServer This cmdlet constructs a shared .NET LibTmux.Server handle without contacting tmux.
Julia LibTmux.Server Server describes an endpoint without contacting tmux. Read its hierarchy with snapshot.
Erlang tmux_server open/1 observes an existing daemon and starts an endpoint owner. Domain rows remain immutable values.
Elixir LibTmux.Server Server describes an existing server by executable and socket. It neither connects nor reserves the server’s identity.
Haskell LibTmux.Server LibTmux.Server owns the Server handle. withServer adopts an existing socket for the length of a callback and releases its own resources afterwards without sending kill-server. Operations such as capture and renameSession are functions of this module that take the handle.
Common Lisp libtmux:client client is a connection scope with one external-operation lease. Closing it cancels owned work and leaves the tmux daemon alive; daemon owns a daemon the library started.
TypeScript server.Server
Rust server.Server
Go tmux.Server
Java io.github.libtmux.Server
Clojure libtmux.core/open! Opens a closeable Java server client for an explicit endpoint. Acquisitions return persistent maps with explicit Java references for effects.
Kotlin io.github.libtmux.kotlin.Server
Scala io.github.libtmux.scaladsl.Server
C# LibTmux.Server
F# LibTmux.FSharp.Server This F# module provides functions over the shared .NET LibTmux.Server type.
C++ libtmux::Server
Swift Server
OCaml Libtmux_unix.Client.t A client is a live, generation-bound server connection. Endpoint describes a socket without connecting; closing a client releases its resources.
Perl LibTmux::Server Construction records connection settings without tmux I/O. Optional LibTmux::Async::Server returns standard Future results for operations.
Esc

Type to search.

Reference previewOpen reference