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.libtmux.Runtime:connect(),Server:close()andServer:observe()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.libtmux.Selection:one(),libtmux.Selection:one_or_nil()andServer:handle()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.Server:snapshot(),libtmux.Snapshot.races,libtmux.Snapshot.completeandlibtmux.SnapshotOptions.strictQuerying 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.Server:query(),Server:query_panes(),Server:explain(),Server:explain_panes(),libtmux.Selection:where(),libtmux.Selection:filter(),libtmux.Selection:first(),libtmux.Selection:count(),libtmux.Selection:exists(),libtmux.query,libtmux.SnapshotSession.window_links,libtmux.SnapshotWindow.panes,libtmux.SnapshotPane.window,libtmux.SnapshotWindowLink.sessionandlibtmux.SnapshotWindowLink.windowChanging 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.Server:new_session(),Server:switch_client()andServer:detach_client()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.Server:get_option(),Server:list_options(),Server:set_option(),Server:unset_option(),Server:get_hook(),Server:list_hooks(),Server:set_hook(),Server:unset_hook(),Server:get_environment(),Server:list_environment(),Server:set_environment(),Server:unset_environment()andServer:remove_environment()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().Server:set_buffer(),Server:show_buffer(),Server:delete_buffer()andServer: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
- set_buffer method
- list_environment method
- show_buffer method
- delete_buffer method
- command method
- set_option 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
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. |
| Elixir | Lib Server describes an existing server by executable and socket. It neither connects nor reserves the server’s identity. |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib This F# module provides functions over the shared .NET LibTmux.Server type. |
| C++ | libtmux:: |
| Swift | Server |