Clients¶
Attached terminals connected to a tmux server
Each client has its own view of the active session, window, and pane
Identified by
client_name(the path or label tmux assigns at attach time)
Bases:
Objtmux(1) Client [client_manual].
A tmux client is an attached terminal. The same tmux server can have multiple clients attached simultaneously (e.g.
$ tmux attachfrom several terminals) and each receives its own view of the active session, window, and pane.Warning
client_session,session_id,window_idandpane_idare snapshots of the client’s currently attached view at the moment this object was read — not stable identity for the client. When the client switches sessions viaswitch-client, moves focus viaselect-window/select-pane, or detaches, these fields go stale untilrefresh()re-reads them fromlist-clients. Theclient_name(tty path on Unix) is the client’s stable identity.Prefer
attached_session(),attached_window(), andattached_pane()when you need the client’s current attachment. Each property re-reads tmux before returning, so theSession/Window/Paneyou get back reflects where the client is attached now, not where it was when thisClientwas constructed. If tmux no longer reports thisclient_namethroughlist-clients, these properties returnNone.attached_pane()follows the attached session’s current window. That can differ from the per-client active pane set byselect-pane -P; seeattached_pane()for the exact behavior. Each property re-reads tmux on every access.- Parameters:
server (
Server)
Examples
>>> with control_mode() as ctl: ... attached = [ ... c ... for c in server.clients ... if c.client_name == ctl.client_name ... ] >>> bool(attached) True
>>> with control_mode() as ctl: ... client = server.clients.get(client_name=ctl.client_name) ... client.client_readonly in {"0", "1"} True
References
[client_manual]- tmux client. openbsd manpage for TMUX(1).
“tmux supports multiple attached clients. Each client has its own keymap, view of the session, and message log.”
https://man.openbsd.org/tmux.1#DESCRIPTION. Accessed 2026.
Refresh client attributes from tmux.
- Raises:
ValueError– Whenclient_nameis unset. Surfaces a clear error underpython -O, where anassertwould be stripped.- Return type:
Create Client from an existing client_name.
Return the
Sessionthis client is currently attached to.Re-reads the client from
list-clientsbefore resolving, so the returnedSessionreflects the client’s live attachment rather than the snapshot captured when thisClientwas read. ReturnsNonewhen tmux no longer reports thisclient_namethroughlist-clients, when the client is not attached to any session, or when the snapshotsession_idno longer names a live session.Examples
>>> with control_mode() as ctl: ... client = server.clients.get(client_name=ctl.client_name) ... attached = client.attached_session >>> attached is not None True
Return the
Windowthis client is currently viewing.Re-reads the client from
list-clients, looks up its attached session, and returns that session’sactive_window. ReturnsNonewhen no live attached session can be resolved.
Return the
Panethis client is currently viewing.Re-reads the client from
list-clients, looks up its attached session’s current window, and returns that window’sactive_pane. ReturnsNonewhen no live attached session or active pane can be resolved.This follows the attached session’s current window and active pane. When a client has used
select-pane -Pto set its own active pane, this property returns the session’s current active pane, not the client’s per-client focus.
Resolve live attachment with a single
list-clientsrefresh.The three
attached_session/attached_window/attached_paneproperties each trigger their ownlist-clientsrefresh — calling them in sequence performs three tmux reads for one conceptual “where is this client attached now” read._resolve_attachedshares a single refresh across the triple and returns the three values together.- Returns:
tuple[Session | None, Window | None, Pane | None] –
(None, None, None)when tmux no longer reports thisclient_namethroughlist-clients, when the client snapshot has nosession_id, or when the snapshotsession_idno longer names a live session.(session, None, None)when the attached session has no active window.(session, window, pane)for a fully-resolved live attachment.paneisNoneonly when the active window has no active pane.
MultipleActiveWindowspropagates rather thancollapsing to
(session, None, None)— multiple active windowsin one session indicates inconsistent tmux state that callers
should see, not absent attachment.
- Return type:
-
__init__(server, active_window_index=None, alternate_saved_x=None, alternate_saved_y=None, buffer_name=None, buffer_sample=None, buffer_size=None, client_activity=None, client_cell_height=None, client_cell_width=None, client_control_mode=None, client_created=None, client_discarded=None, client_flags=None, client_height=None, client_key_table=None, client_last_session=None, client_mode_format=None, client_name=None, client_pid=None, client_prefix=None, client_readonly=None, client_session=None, client_termfeatures=None, client_termname=None, client_termtype=None, client_tty=None, client_uid=None, client_user=None, client_utf8=None, client_width=None, client_written=None, command_list_alias=None, command_list_name=None, command_list_usage=None, config_files=None, copy_cursor_line=None, copy_cursor_word=None, copy_cursor_x=None, copy_cursor_y=None, current_file=None, cursor_character=None, cursor_flag=None, cursor_x=None, cursor_y=None, history_bytes=None, history_limit=None, history_size=None, insert_flag=None, keypad_cursor_flag=None, keypad_flag=None, last_window_index=None, line=None, mouse_all_flag=None, mouse_any_flag=None, mouse_button_flag=None, mouse_sgr_flag=None, mouse_standard_flag=None, next_session_id=None, origin_flag=None, pane_active=None, pane_at_bottom=None, pane_at_left=None, pane_at_right=None, pane_at_top=None, pane_bg=None, pane_bottom=None, pane_current_command=None, pane_current_path=None, pane_dead=None, pane_dead_signal=None, pane_dead_status=None, pane_dead_time=None, pane_fg=None, pane_format=None, pane_height=None, pane_id=None, pane_in_mode=None, pane_index=None, pane_input_off=None, pane_last=None, pane_left=None, pane_marked=None, pane_marked_set=None, pane_mode=None, pane_path=None, pane_pid=None, pane_pipe=None, pane_right=None, pane_search_string=None, pane_start_command=None, pane_start_path=None, pane_synchronized=None, pane_tabs=None, pane_title=None, pane_top=None, pane_tty=None, pane_width=None, pid=None, scroll_position=None, scroll_region_lower=None, scroll_region_upper=None, search_match=None, selection_end_x=None, selection_end_y=None, selection_start_x=None, selection_start_y=None, session_activity=None, session_alerts=None, session_attached=None, session_attached_list=None, session_created=None, session_format=None, session_group=None, session_group_attached=None, session_group_attached_list=None, session_group_list=None, session_group_many_attached=None, session_group_size=None, session_grouped=None, session_id=None, session_last_attached=None, session_many_attached=None, session_marked=None, session_name=None, session_path=None, session_stack=None, session_windows=None, socket_path=None, start_time=None, uid=None, user=None, version=None, window_active=None, window_active_clients=None, window_active_clients_list=None, window_active_sessions=None, window_active_sessions_list=None, window_activity=None, window_activity_flag=None, window_bell_flag=None, window_bigger=None, window_cell_height=None, window_cell_width=None, window_end_flag=None, window_flags=None, window_format=None, window_height=None, window_id=None, window_index=None, window_last_flag=None, window_layout=None, window_linked=None, window_linked_sessions=None, window_linked_sessions_list=None, window_marked_flag=None, window_name=None, window_offset_x=None, window_offset_y=None, window_panes=None, window_raw_flags=None, window_silence_flag=None, window_stack_index=None, window_start_flag=None, window_visible_layout=None, window_width=None, window_zoomed_flag=None, wrap_flag=None)¶method[source]method[source]__init__(server, active_window_index=None, alternate_saved_x=None, alternate_saved_y=None, buffer_name=None, buffer_sample=None, buffer_size=None, client_activity=None, client_cell_height=None, client_cell_width=None, client_control_mode=None, client_created=None, client_discarded=None, client_flags=None, client_height=None, client_key_table=None, client_last_session=None, client_mode_format=None, client_name=None, client_pid=None, client_prefix=None, client_readonly=None, client_session=None, client_termfeatures=None, client_termname=None, client_termtype=None, client_tty=None, client_uid=None, client_user=None, client_utf8=None, client_width=None, client_written=None, command_list_alias=None, command_list_name=None, command_list_usage=None, config_files=None, copy_cursor_line=None, copy_cursor_word=None, copy_cursor_x=None, copy_cursor_y=None, current_file=None, cursor_character=None, cursor_flag=None, cursor_x=None, cursor_y=None, history_bytes=None, history_limit=None, history_size=None, insert_flag=None, keypad_cursor_flag=None, keypad_flag=None, last_window_index=None, line=None, mouse_all_flag=None, mouse_any_flag=None, mouse_button_flag=None, mouse_sgr_flag=None, mouse_standard_flag=None, next_session_id=None, origin_flag=None, pane_active=None, pane_at_bottom=None, pane_at_left=None, pane_at_right=None, pane_at_top=None, pane_bg=None, pane_bottom=None, pane_current_command=None, pane_current_path=None, pane_dead=None, pane_dead_signal=None, pane_dead_status=None, pane_dead_time=None, pane_fg=None, pane_format=None, pane_height=None, pane_id=None, pane_in_mode=None, pane_index=None, pane_input_off=None, pane_last=None, pane_left=None, pane_marked=None, pane_marked_set=None, pane_mode=None, pane_path=None, pane_pid=None, pane_pipe=None, pane_right=None, pane_search_string=None, pane_start_command=None, pane_start_path=None, pane_synchronized=None, pane_tabs=None, pane_title=None, pane_top=None, pane_tty=None, pane_width=None, pid=None, scroll_position=None, scroll_region_lower=None, scroll_region_upper=None, search_match=None, selection_end_x=None, selection_end_y=None, selection_start_x=None, selection_start_y=None, session_activity=None, session_alerts=None, session_attached=None, session_attached_list=None, session_created=None, session_format=None, session_group=None, session_group_attached=None, session_group_attached_list=None, session_group_list=None, session_group_many_attached=None, session_group_size=None, session_grouped=None, session_id=None, session_last_attached=None, session_many_attached=None, session_marked=None, session_name=None, session_path=None, session_stack=None, session_windows=None, socket_path=None, start_time=None, uid=None, user=None, version=None, window_active=None, window_active_clients=None, window_active_clients_list=None, window_active_sessions=None, window_active_sessions_list=None, window_activity=None, window_activity_flag=None, window_bell_flag=None, window_bigger=None, window_cell_height=None, window_cell_width=None, window_end_flag=None, window_flags=None, window_format=None, window_height=None, window_id=None, window_index=None, window_last_flag=None, window_layout=None, window_linked=None, window_linked_sessions=None, window_linked_sessions_list=None, window_marked_flag=None, window_name=None, window_offset_x=None, window_offset_y=None, window_panes=None, window_raw_flags=None, window_silence_flag=None, window_stack_index=None, window_start_flag=None, window_visible_layout=None, window_width=None, window_zoomed_flag=None, wrap_flag=None)¶
- Parameters:
server (
Server)
- Return type:
Refresh dataclass fields from a single
list-*row.Used by the public
refresh()methods onPane,Window,Session, andClient. Each subclass guards its identity field (pane_id,window_id,session_id,client_name) againstNonebefore delegating here; this base method enforces the same precondition explicitly so the guarantee survivespython -O, where anassertwould be stripped.- Raises:
ValueError– Whenobj_idisNone. Surfaces a clear error underpython -O, matching the contract of the publicrefresh()methods.- Parameters:
- Return type: