Server
A handle to one running tmux server, reached through a connected runtime.
Source and package
-
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 (seelibtmux.ConnectOptions). A method that talks to tmux returns alibtmux.Request: calllibtmux.Request:await()from a task the runtime manages, or pass a callback tolibtmux.Request:on_complete(). A failed request reports alibtmux.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()takeslibtmux.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 alibtmux.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, withlibtmux.Selection:one(), which reports no match or several as errors, orlibtmux.Selection:one_or_nil(), which also accepts no match. Pass it, with its snapshot, toServer: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 alibtmux.Snapshotwhose collections are selections. The capture spans several tmux commands, so it is not an atomic view: observed races land inlibtmux.Snapshot.racesand clearlibtmux.Snapshot.complete, andlibtmux.SnapshotOptions.strictadds a verification pass.- Querying things and getting around
Server:query()reads live state and resolves to the rows that match a criteria table, with the snapshot and plan behind them;Server:query_panes()does the same for panes.Server:explain()andServer:explain_panes()return the plan without contacting tmux. On a snapshot already in hand,libtmux.Selection:where()andlibtmux.Selection:filter()narrow a collection in memory, andlibtmux.Selection:first(),libtmux.Selection:count()andlibtmux.Selection:exists()inspect it; thelibtmux.querymodule does the same for ordinary Lua tables. Records lead to each other without another command:libtmux.SnapshotSession.window_links,libtmux.SnapshotWindow.panes,libtmux.SnapshotPane.window,libtmux.SnapshotWindowLink.sessionandlibtmux.SnapshotWindowLink.window.-
query()query_panes()explain()explain_panes()libtmux.Selection:where()libtmux.Selection:filter()libtmux.Selection:first()libtmux.Selection:count()libtmux.Selection:exists()libtmux.querylibtmux.SnapshotSession.window_linkslibtmux.SnapshotWindow.paneslibtmux.SnapshotPane.windowlibtmux.SnapshotWindowLink.sessionlibtmux.SnapshotWindowLink.window
- Changing things
Server:new_session()creates a detached session and resolves to alibtmux.Creationholding 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, andServer:detach_client()detaches it.- Options and hooks
Server:get_option(),Server:list_options(),Server:set_option()andServer:unset_option()address the server's own options; passscope = "global_session"or"global_window"for tmux's global defaults.Server:get_hook(),Server:list_hooks(),Server:set_hook()andServer:unset_hook()need one of those two scopes spelled out. The global environment hasServer:get_environment(),Server:list_environment()andServer:set_environment();Server:unset_environment()deletes a name, whileServer:remove_environment()records a removal marker instead.- Everything else tmux keeps
- Paste buffers, always by explicit name:
Server:set_buffer()stores bytes,Server:show_buffer()reads them back andServer: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 throughServer:command(). - Things that need a terminal
- None. The luv and Neovim adapters do not own an interactive terminal, so
libtmux.Session:attach()returnsunsupported_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, andServer:batch()runs independent commands and reports an outcome for each.
Members30#
Collections and queries3#
- snapshot method
- query_panes method
- query method
Common operations23#
- new_session method
- list_hooks method
- show_buffer method
- set_buffer method
- delete_buffer method
- command method
- set_option method
- list_environment method
- set_environment method
- unset_environment method
- unset_option method
- get_option method
- set_hook method
- unset_hook method
- remove_environment method
- observe method
- handle method Binds a snapshot record to a live handle of its class.
- close method
- detach_client method
- explain method
- explain_panes method
- group method
- switch_client method
Other members4#
- batch method
- get_environment method
- get_hook method
- list_options method
Guides#
Pages that discuss Server.
In other ports#
A tmux server
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| PowerShell | Lib This cmdlet constructs a shared .NET LibTmux.Server handle without contacting tmux. |
| Julia | Lib Server describes an endpoint without contacting tmux. Read its hierarchy with snapshot. |
| Erlang | tmux open/1 observes an existing daemon and starts an endpoint owner. Domain rows remain immutable values. |
| Elixir | Lib 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 |
| Rust | server |
| Go | tmux |
| Java | io |
| Clojure | libtmux Opens a closeable Java server client for an explicit endpoint. Acquisitions return persistent maps with explicit Java references for effects. |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib This F# module provides functions over the shared .NET LibTmux.Server type. |
| C++ | libtmux:: |
| Swift | Server |
| OCaml | Libtmux A client is a live, generation-bound server connection. Endpoint describes a socket without connecting; closing a client releases its resources. |
| Perl | Lib 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.