WindowsΒΆ
- class libtmux.Window[source]ΒΆ
Bases:
Obj
tmux(1) Window [window_manual].
Holds
Pane
objects.- Parameters:
session (
Session
) β
Examples
>>> window = session.new_window('My project', attach=True)
>>> window Window(@2 2:My project, Session($... ...))
Windows have panes:
>>> window.panes [Pane(...)]
>>> window.active_pane Pane(...)
Relations moving up:
>>> window.session Session(...)
>>> window.window_id == session.active_window.window_id True
>>> window == session.active_window True
>>> window in session.windows True
References
[window_manual]- tmux window. openbsd manpage for TMUX(1).
βEach session has one or more windows linked to it. A window occupies the entire screen and may be split into rectangular panesβ¦β
https://man.openbsd.org/tmux.1#DESCRIPTION. Accessed April 1st, 2018.
- property panes: QueryList[Pane]ΒΆ
Panes contained by window.
Can be accessed via
.panes.get()
and.panes.filter()
- cmd(cmd, *args, target=None)[source]ΒΆ
Execute tmux subcommand within window context.
Automatically binds target by adding
-t
for objectβs window ID to the command. Passtarget
to keyword arguments to override.Examples
Create a pane from a window:
>>> window.cmd('split-window', '-P', '-F#{pane_id}').stdout[0] '%...'
Magic, directly to a Pane:
>>> Pane.from_pane_id(pane_id=session.cmd( ... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=session.server) Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
- split(target=None, start_directory=None, attach=False, direction=None, full_window_split=None, zoom=None, shell=None, size=None, environment=None)[source]ΒΆ
Split window on active pane and return the created
Pane
.- Return type:
- Parameters:
attach (bool, optional) β make new window the current window after creating it, default True.
start_directory (str, optional) β specifies the working directory in which the new window is created.
direction (PaneDirection, optional) β split in direction. If none is specified, assume down.
full_window_split (bool, optional) β split across full window width or height, rather than active pane.
zoom (bool, optional) β expand pane
shell (str, optional) β
execute a command on splitting the window. The pane will close when the command exits.
NOTE: When this command exits the pane will close. This feature is useful for long-running processes where the closing of the window upon completion is desired.
size (int, optional) β Cell/row or percentage to occupy with respect to current window.
environment (dict, optional) β Environmental variables for new pane. tmux 3.0+ only. Passthrough to
-e
.
- resize(adjustment_direction=None, adjustment=None, height=None, width=None, expand=None, shrink=None)[source]ΒΆ
Resize tmux window.
- Return type:
- Parameters:
adjustment_direction (ResizeAdjustmentDirection, optional) β direction to adjust,
Up
,Down
,Left
,Right
.adjustment (ResizeAdjustmentDirection, optional) β
height (int, optional) β
resize-window -y
dimensionswidth (int, optional) β
resize-window -x
dimensionsexpand (bool) β expand window
shrink (bool) β shrink window
- Raises:
- Return type:
Notes
Three types of resizing are available:
Adjustments:
adjustment_direction
andadjustment
.Manual resizing:
height
and / orwidth
.Expand or shrink:
expand
orshrink
.
- select_layout(layout=None)[source]ΒΆ
Select layout for window.
Wrapper for
$ tmux select-layout <layout>
.- Return type:
- Parameters:
layout (str, optional) β
string of the layout, βeven-horizontalβ, βtiledβ, etc. Entering None (leaving this blank) is same as
select-layout
with no layout. In recent tmux versions, it picks the most recently set layout.- βeven-horizontalβ
Panes are spread out evenly from left to right across the window.
- βeven-verticalβ
Panes are spread evenly from top to bottom.
- βmain-horizontalβ
A large (main) pane is shown at the top of the window and the remaining panes are spread from left to right in the leftover space at the bottom.
- βmain-verticalβ
Similar to main-horizontal but the large pane is placed on the left and the others spread from top to bottom along the right.
- βtiledβ
Panes are spread out as evenly as possible over the window in both rows and columns.
- βcustomβ
custom dimensions (see tmux(1) manpages).
- set_window_option(option, value)[source]ΒΆ
Set option for tmux window.
Wraps
$ tmux set-window-option <option> <value>
.- Return type:
- Parameters:
- Raises:
exc.OptionError β
- show_window_options(g=False)[source]ΒΆ
Return dict of options for window. :rtype:
Dict
[str
,Any
]Changed in version 0.13.0:
option
removed, use show_window_option to return an individual option.
- show_window_option(option, g=False)[source]ΒΆ
Return option value for the target window.
todo: test and return True/False for on/off string
- Return type:
- Parameters:
- Raises:
exc.OptionError β
- rename_window(new_name)[source]ΒΆ
Rename window.
Examples
>>> window = session.active_window
>>> window.rename_window('My project') Window(@1 1:My project, Session($1 ...))
>>> window.rename_window('New name') Window(@1 1:New name, Session($1 ...))
- kill(all_except=None)[source]ΒΆ
Kill
Window
.$ tmux kill-window
.Examples
Kill a window:
>>> window_1 = session.new_window()
>>> window_1 in session.windows True
>>> window_1.kill()
>>> window_1 not in session.windows True
Kill all windows except the current one:
>>> one_window_to_rule_them_all = session.new_window()
>>> other_windows = session.new_window( ... ), session.new_window()
>>> all([w in session.windows for w in other_windows]) True
>>> one_window_to_rule_them_all.kill(all_except=True)
>>> all([w not in session.windows for w in other_windows]) True
>>> one_window_to_rule_them_all in session.windows True
- new_window(window_name=None, *, start_directory=None, attach=False, window_index='', window_shell=None, environment=None, direction=None)[source]ΒΆ
Create new window respective of current windowβs position.
- Return type:
- Parameters:
See also
Examples
>>> window_initial = session.new_window(window_name='Example') >>> window_initial Window(@... 2:Example, Session($1 libtmux_...)) >>> window_initial.window_index '2'
>>> window_before = window_initial.new_window( ... window_name='Window before', direction=WindowDirection.Before) >>> window_initial.refresh() >>> window_before Window(@... 2:Window before, Session($1 libtmux_...)) >>> window_initial Window(@... 3:Example, Session($1 libtmux_...))
>>> window_after = window_initial.new_window( ... window_name='Window after', direction=WindowDirection.After) >>> window_initial.refresh() >>> window_after.refresh() >>> window_after Window(@... 4:Window after, Session($1 libtmux_...)) >>> window_initial Window(@... 3:Example, Session($1 libtmux_...)) >>> window_before Window(@... 2:Window before, Session($1 libtmux_...))
- select()[source]ΒΆ
Select window.
To select a window object asynchrously. If a
window
object exists and is no longer the current window,w.select_window()
will makew
the current window.- Return type:
Examples
>>> window = session.active_window >>> new_window = session.new_window() >>> session.refresh() >>> active_windows = [w for w in session.windows if w.window_active == '1']
>>> new_window.window_active == '1' False
>>> new_window.select() Window(...)
>>> new_window.window_active == '1' True
- property id: str | NoneΒΆ
Alias of
Window.window_id
.>>> window.id '@1'
>>> window.id == window.window_id True
- property name: str | NoneΒΆ
Alias of
Window.window_name
.>>> window.name '...'
>>> window.name == window.window_name True
- property index: str | NoneΒΆ
Alias of
Window.window_index
.>>> window.index '1'
>>> window.index == window.window_index True
- property height: str | NoneΒΆ
Alias of
Window.window_height
.>>> window.height.isdigit() True
>>> window.height == window.window_height True
- property width: str | NoneΒΆ
Alias of
Window.window_width
.>>> window.width.isdigit() True
>>> window.width == window.window_width True
- split_window(target=None, start_directory=None, attach=False, vertical=True, shell=None, size=None, percent=None, environment=None)[source]ΒΆ
Split window and return the created
Pane
.- Return type:
- Parameters:
Notes
Deprecated since version 0.33.0: Deprecated in favor of
split()
.Changed in version 0.28.0:
attach
default changed fromTrue
toFalse
.Deprecated since version 0.28.0:
percent=25
deprecated in favor ofsize="25%"
.
- property attached_pane: Pane | NoneΒΆ
Return attached
Pane
.Notes
Deprecated since version 0.31: Deprecated in favor of
active_pane()
.
- select_window()[source]ΒΆ
Select window.
- Return type:
Notes
Deprecated since version 0.30: Deprecated in favor of
select()
.
- kill_window()[source]ΒΆ
Kill the current
Window
object.$ tmux kill-window
.- Return type:
Notes
Deprecated since version 0.30: Deprecated in favor of
kill()
.
- get(key, default=None)[source]ΒΆ
Return key-based lookup. Deprecated by attributes. :rtype:
Any
Deprecated since version 0.16: Deprecated by attribute lookup.e.g.
window['window_name']
is now accessed viawindow.window_name
.
- get_by_id(pane_id)[source]ΒΆ
Return pane by id. Deprecated in favor of
panes.get()
. :rtype:Optional
[Pane
]Deprecated since version 0.16: Deprecated by
panes.get()
.
- where(kwargs)[source]ΒΆ
Filter through panes, return list of
Pane
. :rtype:List
[Pane
]Deprecated since version 0.16: Deprecated by
panes.filter()
.
- find_where(kwargs)[source]ΒΆ
Filter through panes, return first
Pane
. :rtype:Optional
[Pane
]Deprecated since version 0.16: Slated to be removed in favor of
panes.get()
.
- _list_panes()[source]ΒΆ
Return list of panes (deprecated in favor of
panes()
). :rtype:List
[Dict
[str
,Any
]]Deprecated since version 0.16: Slated to be removed in favor of
panes
.
- property _panes: List[Dict[str, Any]]ΒΆ
Property / alias to return
_list_panes()
.Deprecated since version 0.16: Slated to be removed in favor of
panes
.
- list_panes()[source]ΒΆ
Return list of
Pane
for the window. :rtype:List
[Pane
]Deprecated since version 0.16: Slated to be removed in favor of
panes
.
- property children: QueryList[Pane]ΒΆ
Was used by TmuxRelationalObject (but thatβs longer used in this class).
Deprecated since version 0.16: Slated to be removed in favor of
panes
.
- __init__(server, active_window_index=None, alternate_saved_x=None, alternate_saved_y=None, buffer_name=None, buffer_sample=None, buffer_size=None, client_cell_height=None, client_cell_width=None, client_discarded=None, client_flags=None, client_height=None, client_key_table=None, client_name=None, client_pid=None, client_termname=None, client_tty=None, client_uid=None, client_user=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_signal=None, pane_dead_status=None, pane_dead_time=None, pane_fg=None, pane_height=None, pane_id=None, pane_index=None, pane_left=None, pane_pid=None, pane_right=None, pane_search_string=None, pane_start_command=None, pane_start_path=None, pane_tabs=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_group=None, session_group_attached=None, session_group_list=None, session_group_size=None, session_id=None, session_last_attached=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_sessions=None, window_activity=None, window_cell_height=None, window_cell_width=None, window_height=None, window_id=None, window_index=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_stack_index=None, window_width=None, wrap_flag=None)[source]ΒΆ
- Parameters:
server (Server) β
active_window_index (str | None) β
alternate_saved_x (str | None) β
alternate_saved_y (str | None) β
buffer_name (str | None) β
buffer_sample (str | None) β
buffer_size (str | None) β
client_cell_height (str | None) β
client_cell_width (str | None) β
client_discarded (str | None) β
client_flags (str | None) β
client_height (str | None) β
client_key_table (str | None) β
client_name (str | None) β
client_pid (str | None) β
client_termname (str | None) β
client_tty (str | None) β
client_uid (str | None) β
client_user (str | None) β
client_width (str | None) β
client_written (str | None) β
command_list_alias (str | None) β
command_list_name (str | None) β
command_list_usage (str | None) β
config_files (str | None) β
copy_cursor_line (str | None) β
copy_cursor_word (str | None) β
copy_cursor_x (str | None) β
copy_cursor_y (str | None) β
current_file (str | None) β
cursor_character (str | None) β
cursor_flag (str | None) β
cursor_x (str | None) β
cursor_y (str | None) β
history_bytes (str | None) β
history_limit (str | None) β
history_size (str | None) β
insert_flag (str | None) β
keypad_cursor_flag (str | None) β
keypad_flag (str | None) β
last_window_index (str | None) β
line (str | None) β
mouse_all_flag (str | None) β
mouse_any_flag (str | None) β
mouse_button_flag (str | None) β
mouse_sgr_flag (str | None) β
mouse_standard_flag (str | None) β
next_session_id (str | None) β
origin_flag (str | None) β
pane_active (str | None) β
pane_at_bottom (str | None) β
pane_at_left (str | None) β
pane_at_right (str | None) β
pane_at_top (str | None) β
pane_bg (str | None) β
pane_bottom (str | None) β
pane_current_command (str | None) β
pane_current_path (str | None) β
pane_dead_signal (str | None) β
pane_dead_status (str | None) β
pane_dead_time (str | None) β
pane_fg (str | None) β
pane_height (str | None) β
pane_id (str | None) β
pane_index (str | None) β
pane_left (str | None) β
pane_pid (str | None) β
pane_right (str | None) β
pane_search_string (str | None) β
pane_start_command (str | None) β
pane_start_path (str | None) β
pane_tabs (str | None) β
pane_top (str | None) β
pane_tty (str | None) β
pane_width (str | None) β
pid (str | None) β
scroll_position (str | None) β
scroll_region_lower (str | None) β
scroll_region_upper (str | None) β
search_match (str | None) β
selection_end_x (str | None) β
selection_end_y (str | None) β
selection_start_x (str | None) β
selection_start_y (str | None) β
session_activity (str | None) β
session_alerts (str | None) β
session_attached (str | None) β
session_attached_list (str | None) β
session_created (str | None) β
session_group (str | None) β
session_group_attached (str | None) β
session_group_list (str | None) β
session_group_size (str | None) β
session_id (str | None) β
session_last_attached (str | None) β
session_name (str | None) β
session_path (str | None) β
session_stack (str | None) β
session_windows (str | None) β
socket_path (str | None) β
start_time (str | None) β
uid (str | None) β
user (str | None) β
version (str | None) β
window_active (str | None) β
window_active_clients (str | None) β
window_active_sessions (str | None) β
window_activity (str | None) β
window_cell_height (str | None) β
window_cell_width (str | None) β
window_height (str | None) β
window_id (str | None) β
window_index (str | None) β
window_layout (str | None) β
window_linked (str | None) β
window_linked_sessions (str | None) β
window_linked_sessions_list (str | None) β
window_marked_flag (str | None) β
window_name (str | None) β
window_offset_x (str | None) β
window_offset_y (str | None) β
window_panes (str | None) β
window_raw_flags (str | None) β
window_stack_index (str | None) β
window_width (str | None) β
wrap_flag (str | None) β
- Return type:
None