- Module
- libtmux
- Package
- libtmux
- Source
- src/libtmux/server.py
- Other languages
- RubyLuaTypeScriptRustGoJava.NETC++Swift
-
tmux(1) Server [server_manual].
-
Server.sessions[Session, ...]-
Session.windows[Window, ...]-
Window.panes[Pane, ...]
-
-
When instantiated stores information on live, running tmux server.
References
- [server_manual]
-
CLIENTS AND SESSIONS. openbsd manpage for TMUX(1) "The tmux server manages clients, sessions, windows and panes. Clients are attached to sessions to interact with them, either when they are created with the new-session command, or later with the attach-session command. Each session has one or more windows linked into it. Windows may be linked to multiple sessions and are made up of one or more panes, each of which contains a pseudo terminal." https://man.openbsd.org/tmux.1#CLIENTS_AND_SESSIONS. Accessed April 1st, 2018.
Discussed in Build a workspace from a file · Python workspace internal API , tmuxp shell · Context managers , Socket and servers
In other ports A tmux server
- Ruby
LibTmux::Server - Lua
libtmux.Server - TypeScript
server.Server - Rust
server.Server - Go
tmux.Server - Java
io.github.libtmux.Server.Server - .NET
LibTmux.Server - C++
libtmux::Server - Swift
Server
-
Examples
>>> serverServer(socket_name=libtmux_test...)>>> server.sessions[Session($1 ...)]>>> server.sessions[0].windows[Window(@1 1:..., Session($1 ...))]>>> server.sessions[0].active_windowWindow(@1 1:..., Session($1 ...))>>> server.sessions[0].active_panePane(%1 Window(@1 1:..., Session($1 ...)))The server can be used as a context manager to ensure proper cleanup:
>>> with Server() as server:... session = server.new_session()... # Do work with the session... # Server will be killed automatically when exiting the contextuse libtmux::test::TestServer;
// In your own code this is `libtmux::Server::new()?`; the fixture keeps// the example off whichever tmux you are actually using.let guard = TestServer::new().await?;let server = guard.server();
server.new_session("work").await?;assert_eq!(server.sessions().await?.len(), 1);
guard.shutdown().await?;74 declared, 24 inherited
Members
- sessions property Sessions contained in server.
- windows property Windows contained in server's sessions.
- panes property Panes contained in tmux server (across all windows in all sessions).
- clients property Clients attached to this tmux server.
- list_buffers method List paste buffers via
$ tmux list-buffers. - list_commands method List tmux commands via
$ tmux list-commands. - list_keys method List key bindings via
$ tmux list-keys. - list_clients method List connected clients via
$ tmux list-clients. - search_panes method All panes across the server, optionally filtered by tmux.
- search_sessions method Sessions, optionally filtered by tmux before rows are returned.
- search_windows method All windows across sessions, optionally filtered by tmux.
- new_session method Create new session, returns new
Session. - source_file method Source a tmux configuration file via
$ tmux source-file. - kill method Kill tmux server.
- set_buffer method Set a paste buffer via
$ tmux set-buffer. - is_alive method Return True if tmux server alive.
- show_buffer method Show content of a paste buffer via
$ tmux show-buffer. - delete_buffer method Delete a paste buffer via
$ tmux delete-buffer. - run_shell method Execute a shell command via
$ tmux run-shell. - has_session method Return True if session exists.
- cmd method Execute tmux command respective of socket name and file, return output.
- wait_for method Wait for, signal, or lock a channel via
$ tmux wait-for. - load_buffer method Load a file into a paste buffer via
$ tmux load-buffer. - save_buffer method Save a paste buffer to a file via
$ tmux save-buffer. - bind_key method Bind a key to a command via
$ tmux bind-key. - unbind_key method Unbind a key via
$ tmux unbind-key. - if_shell method Execute a tmux command conditionally via
$ tmux if-shell. - show_prompt_history method Show prompt history via
$ tmux show-prompt-history. - clear_prompt_history method Clear prompt history via
$ tmux clear-prompt-history. - lock_server method Lock the tmux server via
$ tmux lock-server. - raise_if_dead method Raise if server not connected.
- start_server method Start the tmux server via
$ tmux start-server. - show_messages method Show server message log via
$ tmux show-messages. - command_prompt method Open a command prompt via
$ tmux command-prompt. - display_message method Display message at server scope via
$ tmux display-message. - detach_client method Detach a specific client via
$ tmux detach-client. - kill_session method Kill tmux session.
- from_env method Return the tmux server this process's pane is attached to.
- config_file attribute Passthrough to
[-f file] - socket_path attribute Passthrough to
[-S socket-path] - attached_sessions property Return active
Sessioninstances. - confirm_before method Run a command after confirmation via
$ tmux confirm-before. - display_menu method Display a popup menu via
$ tmux display-menu. - detach_all_clients method Detach every client on this server via
$ tmux detach-client -a. - lock_client method Lock a client via
$ tmux lock-client. - suspend_client method Suspend a client via
$ tmux suspend-client. - refresh_client method Refresh a client's display via
$ tmux refresh-client. - switch_client method Switch tmux client.
- colors attribute
256or88 - socket_name attribute Passthrough to
[-L socket-name] - server_access method Manage server access control via
$ tmux server-access. - attach_session method Attach tmux session.
- child_id_attribute attribute Unique child ID used by
TmuxRelationalObject - default_hook_scope attribute For hook management.
- default_option_scope attribute For option management.
- formatter_prefix attribute Namespace used for
TmuxMappingObject - kill_server method Kill tmux server.
- tmux_bin attribute Custom path to tmux binary. Falls back to
shutil.which("tmux"). - children property Was used by TmuxRelationalObject (but that's longer used in this class).
- find_where method Filter through sessions, return first
Session. - get_by_id method Return session by id. Deprecated in favor of
sessions.get(). - list_sessions method Return list of
Sessionfrom thetmux(1)session. - where method Filter through sessions, return list of
Session. - __enter__ method Enter the context, returning self.
- __eq__ method Equal operator for
Serverobject. - __exit__ method Exit the context, killing the server if it exists.
- __init__ method
- __repr__ method Representation of
Serverobject. - _list_panes method Return list of panes in dict form.
- _list_sessions method Return list of session object dictionaries.
- _list_windows method Return list of windows in dict form.
- _sessions property Property / alias to return
_list_sessions. - _update_panes method Update internal pane data and return
selffor chainability. - _update_windows method Update internal window data and return
selffor chainability.
Inherited members
Reached through libtmux.options.OptionsMixin, libtmux.hooks.HooksMixin, libtmux.common.EnvironmentMixin.
- show_options libtmux.options.OptionsMixin Return all options for the target.
- show_hooks libtmux.hooks.HooksMixin Return a dict of hooks for the target.
- show_environment libtmux.common.EnvironmentMixin Show environment
$ tmux show-environment -t [session]. - set_option libtmux.options.OptionsMixin Set option for tmux target.
- set_environment libtmux.common.EnvironmentMixin Set environment
$ tmux set-environment <name> <value>. - unset_environment libtmux.common.EnvironmentMixin Unset environment variable
$ tmux set-environment -u <name>. - unset_option libtmux.options.OptionsMixin Unset option for tmux target.
- show_option libtmux.options.OptionsMixin Return option value for the target.
- set_hook libtmux.hooks.HooksMixin Set hook for tmux target.
- unset_hook libtmux.hooks.HooksMixin Unset hook for tmux target.
- remove_environment libtmux.common.EnvironmentMixin Remove environment variable
$ tmux set-environment -r <name>. - set_hooks libtmux.hooks.HooksMixin Set multiple indexed hooks at once.
- show_hook libtmux.hooks.HooksMixin Return value for a hook.
- getenv libtmux.common.EnvironmentMixin Show environment variable
$ tmux show-environment -t [session] <name>. - hooks libtmux.hooks.HooksMixin
- run_hook libtmux.hooks.HooksMixin Run a hook immediately. Useful for testing.
- _add_option libtmux.common.EnvironmentMixin
- _show_hook libtmux.hooks.HooksMixin Return value for the hook.
- _show_option libtmux.options.OptionsMixin Return option value for the target.
- _show_option_raw libtmux.options.OptionsMixin Return raw option output for target.
- _show_options libtmux.options.OptionsMixin Return a dict of options for the target.
- _show_options_dict libtmux.options.OptionsMixin Return dict of options for the target.
- _show_options_raw libtmux.options.OptionsMixin Return a dict of options for the target.
- _tmux_bin libtmux.hooks.HooksMixin Resolve tmux_bin from self (Server) or self.server (Session/Window/Pane).