Panes#

class libtmux.Pane(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_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]#

Bases: Obj

A tmux(1) Pane [pane_manual].

Pane instances can send commands directly to a pane, or traverse between linked tmux objects.

window#
Type:

Window

Examples

>>> pane
Pane(%1 Window(@1 1:..., Session($1 ...)))
>>> pane in window.panes
True
>>> pane.window
Window(@1 1:..., Session($1 ...))
>>> pane.session
Session($1 ...)

Notes

Changed in version 0.8: Renamed from .tmux to .cmd.

References

[pane_manual]
tmux pane. openbsd manpage for TMUX(1).

β€œEach window displayed by tmux may be split into one or more panes; each pane takes up a certain area of the display and is a separate terminal.”

https://man.openbsd.org/tmux.1#WINDOWS_AND_PANES. Accessed April 1st, 2018.

cmd(cmd, *args, **kwargs)[source]#

Return Server.cmd() defaulting to target_pane as target.

Send command to tmux with pane_id as target-pane.

Specifying ('-t', 'custom-target') or ('-tcustom_target') in args will override using the object’s pane_id as target.

Return type:

tmux_cmd

resize_pane(*args, **kwargs)[source]#

$ tmux resize-pane of pane and return self.

Parameters:
  • target_pane (str) – target_pane, or -U,``-D``, -L, -R.

  • height (int) – resize-pane -y dimensions

  • width (int) – resize-pane -x dimensions

Raises:

exc.LibTmuxException –

Return type:

Pane

capture_pane(start=None, end=None)[source]#

Capture text from pane.

$ tmux capture-pane to pane. $ tmux capture-pane -S -10 to pane. ``$ tmux capture-pane`-E 3` to pane. ``$ tmux capture-pane`-S - -E -` to pane.

Parameters:
  • start ([str,int]) – Specify the starting line number. Zero is the first line of the visible pane. Positive numbers are lines in the visible pane. Negative numbers are lines in the history. β€˜-’ is the start of the history. Default: None

  • end ([str,int]) – Specify the ending line number. Zero is the first line of the visible pane. Positive numbers are lines in the visible pane. Negative numbers are lines in the history. β€˜-’ is the end of the visible pane Default: None

Return type:

Union[str, List[str]]

send_keys(cmd, enter=True, suppress_history=False, literal=False)[source]#

$ tmux send-keys to the pane.

A leading space character is added to cmd to avoid polluting the user’s history.

Parameters:
  • cmd (str) – Text or input into pane

  • enter (bool, optional) – Send enter after sending the input, default True.

  • suppress_history (bool, optional) –

    Prepend a space to command to suppress shell history, default False.

    Changed in version 0.14: Default changed from True to False.

  • literal (bool, optional) – Send keys literally, default True.

Examples

>>> pane = window.split_window(shell='sh')
>>> pane.capture_pane()
['$']
>>> pane.send_keys('echo "Hello world"', enter=True)
>>> pane.capture_pane()
['$ echo "Hello world"', 'Hello world', '$']
>>> print('\n'.join(pane.capture_pane()))  
$ echo "Hello world"
Hello world
$
Return type:

None

display_message(cmd: str, get_text: Literal[True]) Union[str, List[str]][source]#
display_message(cmd: str, get_text: Literal[False]) None

$ tmux display-message to the pane.

Displays a message in target-client status line.

Parameters:
  • cmd (str) – Special parameters to request from pane.

  • get_text (bool, optional) – Returns only text without displaying a message in target-client status line.

Return type:

Union[str, List[str], None]

select_pane()[source]#

Select pane. Return self.

To select a window object asynchrously. If a pane object exists and is no longer longer the current window, w.select_pane() will make p the current pane.

Return type:

Pane

split_window(attach=False, vertical=True, start_directory=None, percent=None)[source]#

Split window at pane and return newly created Pane.

Parameters:
  • attach (bool, optional) – Attach / select pane after creation.

  • vertical (bool, optional) – split vertically

  • start_directory (str, optional) – specifies the working directory in which the new pane is created.

  • percent (int, optional) – percentage to occupy with respect to current pane

Return type:

Pane

set_width(width)[source]#

Set width of pane.

Parameters:

width (int) – pane width, in cells

Return type:

Pane

set_height(height)[source]#

Set height of pane.

Parameters:

height (int) – height of pain, in cells

Return type:

Pane

enter()[source]#

Send carriage return to pane.

$ tmux send-keys send Enter to the pane.

Return type:

Pane

clear()[source]#

Clear pane.

Return type:

Pane

reset()[source]#

Reset and clear pane history.

Return type:

Pane

property id: Optional[str]#

Alias of Pane.pane_id

>>> pane.id
'%1'
>>> pane.id == pane.pane_id
True
Return type:

Optional[str]

property index: Optional[str]#

Alias of Pane.pane_index

>>> pane.index
'0'
>>> pane.index == pane.pane_index
True
Return type:

Optional[str]

property height: Optional[str]#

Alias of Pane.pane_height

>>> pane.height.isdigit()
True
>>> pane.height == pane.pane_height
True
Return type:

Optional[str]

property width: Optional[str]#

Alias of Pane.pane_width

>>> pane.width.isdigit()
True
>>> pane.width == pane.pane_width
True
Return type:

Optional[str]

get(key, default=None)[source]#

Deprecated since version 0.16.

Return type:

Any