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.
Server the object was queried from, and the connection every refresh re-runs its
list-*command over.
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, bracket_paste_flag=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_flags=None, pane_floating_flag=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_pb_progress=None, pane_pb_state=None, pane_pid=None, pane_pipe=None, pane_pipe_pid=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, pane_x=None, pane_y=None, pane_z=None, pane_zoomed_flag=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, synchronized_output_flag=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, bracket_paste_flag=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_flags=None, pane_floating_flag=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_pb_progress=None, pane_pb_state=None, pane_pid=None, pane_pipe=None, pane_pipe_pid=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, pane_x=None, pane_y=None, pane_z=None, pane_zoomed_flag=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, synchronized_output_flag=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:
Index of the session’s active window.
Saved cursor X position for the pane’s alternate screen.
Saved cursor Y position for the pane’s alternate screen.
"1"when the pane’s terminal has bracketed paste mode enabled.
Name of the buffer.
Sample taken from the start of the buffer’s contents.
Size of the buffer, in bytes.
Time the client last had activity.
Height of one of the client’s terminal cells, in pixels.
Width of one of the client’s terminal cells, in pixels.
"1"when the client is running in control mode.
Time the client was created.
Bytes discarded because the client fell behind.
List of the client’s flags.
Height of the client, in cells.
Name of the key table the client is currently using.
Name of the session the client was attached to before its current one.
Default format string tmux’s client mode (
choose-client) renders each client row with.
Name of the client.
PID of the client process.
"1"while the prefix key has been pressed.
"1"when the client is attached read-only.
Name of the session the client is attached to.
Terminal features tmux detected for the client, if any.
Terminal name of the client.
Terminal type of the client, if available.
Path to the client’s pseudo terminal.
UID of the client process.
User the client process runs as.
"1"when the client supports UTF-8.
Width of the client, in cells.
Bytes written to the client.
Command alias, when listing commands.
Command name, when listing commands.
Command usage string, when listing commands.
List of the configuration files tmux loaded.
Text of the line the cursor sits on in copy mode.
Word under the cursor in copy mode.
Cursor X position in copy mode.
Cursor Y position in copy mode.
Configuration file currently being parsed.
Character at the pane’s cursor position.
"1"when the pane’s cursor is visible.
Cursor X position in the pane.
Cursor Y position in the pane.
Bytes held in the pane’s scrollback history.
Maximum number of scrollback lines the pane keeps.
Lines currently held in the pane’s scrollback history.
"1"when the pane’s terminal is in insert mode.
"1"when the pane’s terminal is in application cursor key mode.
"1"when the pane’s terminal is in application keypad mode.
Index of the last window in the session.
Row number tmux assigns to the entry in the listing.
"1"when the pane’s terminal has all-motion mouse reporting enabled.
"1"when the pane’s terminal has any mouse reporting mode enabled.
"1"when the pane’s terminal has button-event mouse reporting enabled.
"1"when the pane’s terminal reports mouse events in SGR form.
"1"when the pane’s terminal has standard mouse reporting enabled.
Session ID tmux will give the next new session.
"1"when the pane’s terminal is in origin mode.
"1"when this is the active pane of its window.
"1"when the pane touches the bottom of the window.
"1"when the pane touches the left of the window.
"1"when the pane touches the right of the window.
"1"when the pane touches the top of the window.
Bottom edge of the pane, as a window row.
Command running in the pane, if available.
Working directory of the pane, if available.
"1"when the pane’s process has exited and the pane is dead.
Signal that killed the process in a dead pane.
Exit status of the process in a dead pane.
Time the process in a dead pane exited.
Pane flags:
*for the active pane,-for the last used,Zfor zoomed,Ffor floating.
"1"when the pane is floating.
"1"when the format is being evaluated for a pane.
Height of the pane, in cells.
Unique pane ID, e.g.
"%3"(the#Dalias).
Number of modes the pane is in.
Index of the pane within its window (the
#Palias).
"1"when input to the pane is disabled.
"1"when this is the window’s last used pane.
Left edge of the pane, as a window column.
"1"when this pane is the marked pane.
"1"when a marked pane is set on the server.
Name of the mode the pane is in, if any.
Path of the pane; the application running in it can set this.
Progress percentage of the pane’s progress bar; the application running in it can set this.
Pane progress bar state, one of
hidden,normal,error,indeterminate, orpaused; the application running in the pane can set this.
PID of the first process started in the pane.
"1"while the pane’s output is being piped.
PID of the pipe process, if any.
Right edge of the pane, as a window column.
Last search string used in the pane’s copy mode.
Command the pane was started with.
Working directory the pane was started in.
"1"when the pane hassynchronize-panesin effect.
Tab stop positions in the pane.
Title of the pane; the application running in it can set this (the
#Talias).
Top edge of the pane, as a window row.
Path to the pane’s pseudo terminal.
Width of the pane, in cells.
"1"when the pane is zoomed.
Scroll position in copy mode.
Bottom line of the pane’s scroll region.
Top line of the pane’s scroll region.
Search match in the pane’s copy mode, if any.
X position of the end of the copy-mode selection.
Y position of the end of the copy-mode selection.
X position of the start of the copy-mode selection.
Y position of the start of the copy-mode selection.
Time of the session’s last activity.
List of indexes of the session’s windows with alerts.
Number of clients attached to the session.
List of the clients attached to the session.
Time the session was created.
"1"when the format is being evaluated for a session.
Name of the session group the session belongs to.
Number of clients attached to sessions in the session group.
List of the clients attached to sessions in the session group.
List of the sessions in the session group.
"1"when more than one client is attached to sessions in the session group.
Number of sessions in the session group.
"1"when the session belongs to a session group.
Unique session ID, e.g.
"$1".
Time the session was last attached.
"1"when more than one client is attached to the session.
"1"when the session contains the marked pane.
Name of the session (the
#Salias).
Working directory of the session.
Indexes of the session’s windows, most recently used first.
Number of windows in the session.
Path to the tmux server’s socket.
Time the tmux server started.
"1"when the pane’s terminal has synchronized output enabled.
Version of the running tmux server.
"1"when the window is its session’s current window.
Number of clients viewing the window.
List of the clients viewing the window.
Number of sessions in which the window is the active one.
List of the sessions in which the window is the active one.
Time of the window’s last activity.
"1"when the window has an activity alert.
"1"when the window has a bell alert.
"1"when the window is larger than the client viewing it.
Height of one of the window’s cells, in pixels.
Width of one of the window’s cells, in pixels.
"1"when the window has the highest index in the session.
Window flags, with
#escaped as##(the#Falias).
"1"when the format is being evaluated for a window.
Height of the window, in cells.
Unique window ID, e.g.
"@2".
Index of the window in its session (the
#Ialias).
"1"when the window is the session’s last used one.
Window layout description, ignoring zoomed panes.
"1"when the window is linked across sessions.
Number of sessions the window is linked into.
List of the sessions the window is linked into.
"1"when the window contains the marked pane.
Name of the window (the
#Walias).
X offset into the window when it is larger than the client.
Y offset into the window when it is larger than the client.
Number of panes in the window.
Window flags, with nothing escaped.
"1"when the window has a silence alert.
Index of the window in its session’s most recently used stack.
"1"when the window has the lowest index in the session.
Window layout description, respecting zoomed panes.
Width of the window, in cells.
"1"when the window is zoomed.