Panes#

class libtmux.Pane(window, pane_id, **kwargs)[source]#

Bases: TmuxMappingObject

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.

formatter_prefix: str = 'pane_'#

Namespace used for TmuxMappingObject

window: Window#

libtmux.Window pane is linked to

session: Session#

libtmux.Session pane is linked to

server: Server#

libtmux.Server pane is linked to

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:

Server.cmd

Return type:

tmux_cmd

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.

Returns:

Return type:

Union[str, List[str], None]

clear()[source]#

Clear pane.

Return type:

None

get(k[, d]) D[k] if k in D, else d.  d defaults to None.[source]#
items() a set-like object providing a view on D's items[source]#
keys()[source]#

Return list of keys.

Return type:

KeysView[str]

reset()[source]#

Reset and clear pane history.

Return type:

None

values() an object providing a view on D's values[source]#
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

Return type:

Pane

set_width(width)[source]#

Set width of pane.

Parameters:

width (int) – pane width, in cells

Return type:

None

set_height(height)[source]#

Set height of pane.

Parameters:

height (int) – height of pain, in cells

Return type:

None

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

Return type:

Pane

Raises:

exc.LibTmuxException –

Return type:

Pane

enter()[source]#

Send carriage return to pane.

$ tmux send-keys send Enter to the pane.

Return type:

None

capture_pane()[source]#

Capture text from pane.

$ tmux capture-pane to pane.

Return type:

list

Return type:

Union[str, List[str]]

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

Return type:

Pane