Core LibraryunreleasedAPI reference

Choose documentation 3

latest

Current version

latest
English

Unreleased LibTmux has not been released. Its API may change during development. This site's structure and URLs may change too.

MoreLess about this notice

struct LibTmux.jl

Server

Describe a tmux endpoint without contacting it. Name at most one socket. A description does not own a daemon or any sessions.

Source and package
Qualified name
LibTmux.Server
Module
LibTmux
Package
LibTmux
Source
src/server.jl

Description

Server(; socket_path=nothing, socket_name=nothing, tmux="tmux", env=ENV)

socket_path selects a socket file with tmux's -S and socket_name a named socket with -L; naming both raises ArgumentError. With neither, env is read: LIBTMUX_SOCKET_PATH selects a socket file and LIBTMUX_SOCKET a named socket, the path first when both are set. A variable that is empty or only whitespace counts as unset, each one alone. A socket named in the call leaves both variables unread. When neither variable is set the server names no socket and passes tmux neither -S nor -L, so tmux picks the server itself: the one TMUX names inside tmux, otherwise its default socket. Use from_env to ask for the TMUX socket as an explicit path.

LIBTMUX_SOCKET names a socket, so a value that holds a slash raises ArgumentError; put a path in LIBTMUX_SOCKET_PATH. A relative path, from the variable or from socket_path, is made absolute against the working directory when the Server is built.

env is only the mapping those two variables are read from. It is not the environment a tmux command gets, which is the env of run_command, so Server(env=Dict("TMUX_TMPDIR" => dir)) changes nothing. The choice is made when the Server is built and kept in the value. A Server held in a const keeps the variables of the process that built it, which under precompilation is the precompiling process.

A server that names no socket also leaves TMUX and TMUX_PANE in the environment of its commands. A command with no target then acts on the pane TMUX_PANE names, so a bare kill-pane through run_command kills the caller's own pane. A named socket drops both variables.

tmux is the executable; a bare name is resolved through PATH when an operation runs. Construction validates the arguments and does not check that the executable or the socket exists. A Server is an immutable value with nothing to close, and the daemon it names may not be running yet: new_session can start one at this endpoint.

What is on here

A tmux server does a great many things, so this package has a great many functions that take one. In Julia they sit beside the type rather than on it: each takes a Server as its first argument, and most also have a method for a ControlConnection. Functions that run tmux accept timeout and cancel keywords, where cancel takes a CancellationToken. They fall into a few groups:

Connecting
Server itself only describes an endpoint. Ask for the endpoint named by TMUX when this process is inside tmux, or for the default socket when it is not. Start a private daemon you own and get back an OwnedServer, or run a function against one and close it afterwards. Attach a ControlConnection to one session; the output, notification, and format-subscription functions need that connection.
The endpoint named in the environment
Start a private daemon
Run a function, then close it
Attach to one session
Finding one thing
Operations act on references, each tied to the daemon it came from. Creating a session, window, or pane returns the reference to what it creates, and a captured session, window, pane, or client carries its own as .ref. A Server has no lookup by name: take a snapshot and give the matching function a criterion, such as SessionWhere, and one of the snapshot's collections. The matching function raises NoMatchError or MultipleMatchesError instead of choosing for you.
Capture
Match exactly one
Listing everything
Take a snapshot to capture every session, window, pane, and attached client into a Snapshot; the call raises when tmux does not answer, so an outage never reads as an empty server. Listing what a snapshot holds does not contact tmux again. A snapshot is a point-in-time copy that never refreshes; take another to see later changes.
Capture
Querying things and getting around
Criteria are Criterion values that match captured records with no I/O. Pass one to filter, and the Selection it returns keeps its snapshot. To move between levels, go down from a session or a window and up from a pane, a window link, or a client. A record can be asked for the snapshot it came from.
Windows of a session, down
Panes of a window, down
Window of a pane or window link, up
Session of a client or window link, up
Snapshot a record came from
Changing things
Creating a session, window, or pane returns its reference, and killing one removes it. The rest rearrange what is there: renaming, resizing, respawning, selecting, swapping, moving, linking, and unlinking. Each function acts on tmux when called and returns a CommandResult unless it creates something.
End a borrowed server, only when told to
Link and unlink
Options and hooks
Getting, setting, and unsetting options work at a scope such as :server, :global_session, or a session, window, or pane reference. The hook functions work the same way, but hooks have no :server scope. The environment can be read, set, unset, and removed: unsetting deletes an entry, and removing marks a variable for removal from new processes.
Read and set the environment
Delete an entry
Remove from new processes
Everything else tmux keeps
For paste buffers, the load function returns a reference that the delete function releases, and the save function reads one back. Paste text or bytes into a pane; each goes through a temporary buffer. Send keys to a pane, and read its screen back as text or as bytes. For formats, one function reads typed fields, one expands a raw expression, and one lists candidate names.
Load a buffer
Release it
Read one back
Send keys to a pane
Screen as text
Screen as bytes
Read typed fields
Expand a raw expression
List candidate names
Things that need a terminal
Popups, menus, and prompts, which draw on an attached client's terminal, have no function here. Switching and detaching act on a client that is already attached.
Switch a client
Detach a client
Running a command
Anything tmux can do that is not here is reachable by running a tmux command with literal arguments, or by running several TmuxCommand values as one semicolon group or as independent commands.
One command with literal arguments
Several as one semicolon group
Several as independent commands

Methods

[source]

Parameters

Fields3 fields

Common operations1

Other members2

Guides

task material

Pages that discuss Server.

In other ports

task equivalence 22 other ports mapped

Source-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.

A tmux server in each port
PortAPIDiffers from Julia
Julia LibTmux.Server
Describe a tmux endpoint without contacting it. Name at most one socket. A description does not own a daemon or any sessions.
This page
Python libtmux.Server
tmux(1) Server [server_manual].
None recorded in the model
Ruby LibTmux::Server
Connects to an existing endpoint. Closing retires clients, never the daemon.
None recorded in the model
Lua libtmux.Server None recorded in the model
PowerShell LibTmux\New-TmuxServer
Construct a tmux endpoint handle without contacting it.
2 overloads
This cmdlet constructs a shared .NET LibTmux.Server handle without contacting tmux.
Erlang tmux_server
Open tmux endpoints and execute explicit command values.
open/1 observes an existing daemon and starts an endpoint owner. Domain rows remain immutable values.
Elixir LibTmux.Server
An explicit local tmux server descriptor.
Server describes an existing server by executable and socket. It neither connects nor reserves the server’s identity.
Haskell LibTmux.Server
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:client
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.
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
One tmux server, addressed by the socket it listens on.
None recorded in the model
Rust server.Server
A cloneable handle to one captured tmux server endpoint.
None recorded in the model
Go tmux.Server
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.github.libtmux.Server
Manages sessions, windows, and panes on a tmux server.
readonly
Clojure libtmux.core/open!
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.github.libtmux.kotlin.Server
Manages sessions, windows, and panes on a tmux server.
None recorded in the model
Scala io.github.libtmux.scaladsl.Server
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# LibTmux.Server
Represents an immutable server handle and snapshot.
None recorded in the model
F# LibTmux.FSharp.Server
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::Server
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_unix.Client
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 LibTmux::Server
Explicit tmux acquisition and commands
Construction records connection settings without tmux I/O. Optional LibTmux::Async::Server returns standard Future results for operations.
Raku LibTmux::Server None recorded in the model
Esc
Search in

Type to search.

Reference previewOpen reference