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-lua latest

Server

A handle to one running tmux server, reached through a connected runtime.

Source and package
Qualified name
libtmux.Server
Module
libtmux
Package
libtmux
Source
lua/libtmux/_internal/server.lua
Other languages
Perlclass Erlangmodule PowerShellcmdlet Juliastruct Elixirstruct Haskell Common Lisp PythonRubyTypeScriptRustGoJavaC#C++SwiftKotlinScalaOCamltypealias F#module Clojurefunction
class libtmux.Server

Description#

libtmux.Runtime:connect() resolves to a server for a daemon that is already running. The library never starts a daemon, and closing the handle leaves the daemon running. With no socket named it passes tmux none, and tmux picks the server (see libtmux.ConnectOptions). A method that talks to tmux returns a libtmux.Request: call libtmux.Request:await() from a task the runtime manages, or pass a callback to libtmux.Request:on_complete(). A failed request reports a libtmux.Error. If the daemon restarts or its socket is replaced, the handle stops working and the caller connects again.

What is on here

A tmux server does a great many things, so this class has a great many methods. They fall into a few groups:

Connecting
libtmux.Runtime:connect() takes libtmux.ConnectOptions: an absolute path to the tmux binary and, optionally, to the daemon's socket. Server:close() closes the connections the handle owns. Server:observe() takes a session handle and resolves to a libtmux.Observation, a control-mode view of that session whose watches report pane output, notifications and format values.
Finding one thing
Take one record from a libtmux.Snapshot, or from the rows of a query, with libtmux.Selection:one(), which reports no match or several as errors, or libtmux.Selection:one_or_nil(), which also accepts no match. Pass it, with its snapshot, to Server:handle(): that binds the record to a live session, window, window link, pane, client or buffer handle of the same class, and returns it directly rather than as a request.
Listing everything
Server:snapshot() lists sessions, windows, window links, panes, clients and buffers, and resolves to a libtmux.Snapshot whose collections are selections. The capture spans several tmux commands, so it is not an atomic view: observed races land in libtmux.Snapshot.races and clear libtmux.Snapshot.complete, and libtmux.SnapshotOptions.strict adds a verification pass.
Changing things
Server:new_session() creates a detached session and resolves to a libtmux.Creation holding handles for the session and the window, pane and window link it starts with. Server:switch_client() points an attached client, selected by the name and TTY a snapshot reports, at a session handle, and Server:detach_client() detaches it.
Everything else tmux keeps
Paste buffers, always by explicit name: Server:set_buffer() stores bytes, Server:show_buffer() reads them back and Server:delete_buffer() removes the buffer. None infers the most recent buffer. Key bindings, configuration files, shell jobs and wait-for channels have no method here; reach them through Server:command().
Things that need a terminal
None. The luv and Neovim adapters do not own an interactive terminal, so libtmux.Session:attach() returns unsupported_tty.
Running a command
Anything tmux can do that is not here is reachable through Server:command(), which runs one tmux command from literal arguments and resolves to its stdout, stderr, exit code and signal; a nonzero exit is reported in that result, not as a failure. Server:group() sends several commands as one ordered group with a single aggregate result, and Server:batch() runs independent commands and reports an outcome for each.

Members30#

Collections and queries3#

Common operations23#

Other members4#

Guides#

Pages that discuss Server.

In other ports#

A tmux server

Equivalents of A tmux server in other languages
Language Equivalent
Python libtmux.Server
Ruby 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 No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
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.

No equivalent is recorded in Common Lisp.

Esc

Type to search.

Reference previewOpen reference