libtmux Reference MCP Search
On this page

libtmux.Server

View as Markdown

Module
libtmux
Package
libtmux
Source
src/libtmux/server.py
class libtmux.Server
class [source]
class [source]
class libtmux.Server

tmux(1) Server [server_manual].

When instantiated stores information on live, running tmux server.

Examples

>>> server
Server(socket_name=libtmux_test...)
>>> server.sessions
[Session($1 ...)]
>>> server.sessions[0].windows
[Window(@1 1:..., Session($1 ...))]
>>> server.sessions[0].active_window
Window(@1 1:..., Session($1 ...))
>>> server.sessions[0].active_pane
Pane(%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 context

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.

74 declared, 24 inherited

Members

  • child_id_attribute attribute Unique child ID used by TmuxRelationalObject
  • colors attribute 256 or 88
  • config_file attribute Passthrough to [-f file]
  • default_hook_scope attribute For hook management.
  • default_option_scope attribute For option management.
  • formatter_prefix attribute Namespace used for TmuxMappingObject
  • socket_name attribute Passthrough to [-L socket-name]
  • socket_path attribute Passthrough to [-S socket-path]
  • tmux_bin attribute Custom path to tmux binary. Falls back to shutil.which("tmux").
  • __enter__ method Enter the context, returning self.
  • __eq__ method Equal operator for Server object.
  • __exit__ method Exit the context, killing the server if it exists.
  • __init__ method
  • __repr__ method Representation of Server object.
  • _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.
  • _update_panes method Update internal pane data and return self for chainability.
  • _update_windows method Update internal window data and return self for chainability.
  • attach_session method Attach tmux session.
  • bind_key method Bind a key to a command via $ tmux bind-key.
  • clear_prompt_history method Clear prompt history via $ tmux clear-prompt-history.
  • cmd method Execute tmux command respective of socket name and file, return output.
  • command_prompt method Open a command prompt via $ tmux command-prompt.
  • confirm_before method Run a command after confirmation via $ tmux confirm-before.
  • delete_buffer method Delete a paste buffer via $ tmux delete-buffer.
  • detach_all_clients method Detach every client on this server via $ tmux detach-client -a.
  • detach_client method Detach a specific client via $ tmux detach-client.
  • display_menu method Display a popup menu via $ tmux display-menu.
  • display_message method Display message at server scope via $ tmux display-message.
  • find_where method Filter through sessions, return first Session .
  • from_env method Return the tmux server this process's pane is attached to.
  • get_by_id method Return session by id. Deprecated in favor of sessions.get().
  • has_session method Return True if session exists.
  • if_shell method Execute a tmux command conditionally via $ tmux if-shell.
  • is_alive method Return True if tmux server alive.
  • kill method Kill tmux server.
  • kill_server method Kill tmux server.
  • kill_session method Kill tmux session.
  • list_buffers method List paste buffers via $ tmux list-buffers.
  • list_clients method List connected clients via $ tmux list-clients.
  • list_commands method List tmux commands via $ tmux list-commands.
  • list_keys method List key bindings via $ tmux list-keys.
  • list_sessions method Return list of Session from the tmux(1) session.
  • load_buffer method Load a file into a paste buffer via $ tmux load-buffer.
  • lock_client method Lock a client via $ tmux lock-client.
  • lock_server method Lock the tmux server via $ tmux lock-server.
  • new_session method Create new session, returns new Session .
  • raise_if_dead method Raise if server not connected.
  • refresh_client method Refresh a client's display via $ tmux refresh-client.
  • run_shell method Execute a shell command via $ tmux run-shell.
  • save_buffer method Save a paste buffer to a file via $ tmux save-buffer.
  • 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.
  • server_access method Manage server access control via $ tmux server-access.
  • set_buffer method Set a paste buffer via $ tmux set-buffer.
  • show_buffer method Show content of a paste buffer via $ tmux show-buffer.
  • show_messages method Show server message log via $ tmux show-messages.
  • show_prompt_history method Show prompt history via $ tmux show-prompt-history.
  • source_file method Source a tmux configuration file via $ tmux source-file.
  • start_server method Start the tmux server via $ tmux start-server.
  • suspend_client method Suspend a client via $ tmux suspend-client.
  • switch_client method Switch tmux client.
  • unbind_key method Unbind a key via $ tmux unbind-key.
  • wait_for method Wait for, signal, or lock a channel via $ tmux wait-for.
  • where method Filter through sessions, return list of Session .
  • _sessions property Property / alias to return _list_sessions .
  • attached_sessions property Return active Session instances.
  • children property Was used by TmuxRelationalObject (but that's longer used in this class).
  • clients property Clients attached to this tmux server.
  • panes property Panes contained in tmux server (across all windows in all sessions).
  • sessions property Sessions contained in server.
  • windows property Windows contained in server's sessions.

Inherited members

Reached through libtmux.common.EnvironmentMixin, libtmux.hooks.HooksMixin, libtmux.options.OptionsMixin.

  • _add_option libtmux.common.EnvironmentMixin
  • hooks libtmux.hooks.HooksMixin
  • _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.
  • getenv libtmux.common.EnvironmentMixin Show environment variable $ tmux show-environment -t [session] <name>.
  • remove_environment libtmux.common.EnvironmentMixin Remove environment variable $ tmux set-environment -r <name>.
  • run_hook libtmux.hooks.HooksMixin Run a hook immediately. Useful for testing.
  • set_environment libtmux.common.EnvironmentMixin Set environment $ tmux set-environment <name> <value>.
  • set_hook libtmux.hooks.HooksMixin Set hook for tmux target.
  • set_hooks libtmux.hooks.HooksMixin Set multiple indexed hooks at once.
  • set_option libtmux.options.OptionsMixin Set option for tmux target.
  • show_environment libtmux.common.EnvironmentMixin Show environment $ tmux show-environment -t [session].
  • show_hook libtmux.hooks.HooksMixin Return value for a hook.
  • show_hooks libtmux.hooks.HooksMixin Return a dict of hooks for the target.
  • show_option libtmux.options.OptionsMixin Return option value for the target.
  • show_options libtmux.options.OptionsMixin Return all options for the target.
  • unset_environment libtmux.common.EnvironmentMixin Unset environment variable $ tmux set-environment -u <name>.
  • unset_hook libtmux.hooks.HooksMixin Unset hook for tmux target.
  • unset_option libtmux.options.OptionsMixin Unset option for tmux target.
  • _tmux_bin libtmux.hooks.HooksMixin Resolve tmux_bin from self (Server) or self.server (Session/Window/Pane).
Esc

Type to search.