Panes

class libtmux.Pane(window=None, **kwargs)

Bases: libtmux.common.TmuxMappingObject, libtmux.common.TmuxRelationalObject

A tmux(1) pane [1].

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

Parameters:window (Window) –

Notes

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

References

[1]
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 = u'pane_'

namespace used TmuxMappingObject

cmd(cmd, *args, **kwargs)

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.

Returns:
Return type:Server.cmd
send_keys(cmd, enter=True, suppress_history=True)

$ 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) – Don’t add these keys to the shell history, default True.
display_message(cmd, get_text=False)

$ 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:

clear()

Clear pane.

reset()

Reset and clear pane history.

split_window(attach=False, vertical=True, start_directory=None)

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.
Returns:

Return type:

Pane

set_width(width)

Set width of pane.

Parameters:width (int) – pane width, in cells
set_height(height)

Set height of pane.

Parameters:height (int) – height of pain, in cells
resize_pane(*args, **kwargs)

$ tmux resize-pane of pane and return self.

Parameters:

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

Other Parameters:
 
  • height (int) – resize-pane -y dimensions
  • width (int) – resize-pane -x dimensions
Returns:

Return type:

Pane

Raises:

exc.LibTmuxException

enter()

Send carriage return to pane.

$ tmux send-keys send Enter to the pane.

capture_pane()

Capture text from pane.

$ tmux capture-pane to pane.

Returns:
Return type:list
select_pane()

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.

Returns:
Return type:pane
find_where(attrs)

Return object on first match.

Changed in version 0.4: Renamed from .findWhere to .find_where.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
get_by_id(id)

Return object based on child_id_attribute.

Parameters:val (str) –
Returns:
Return type:object

Notes

Based on .get() from backbone.js.

items() → list of D's (key, value) pairs, as 2-tuples
iteritems() → an iterator over the (key, value) items of D
iterkeys() → an iterator over the keys of D
itervalues() → an iterator over the values of D
keys()

Return list of keys.

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → list of D's values
where(attrs, first=False)

Return objects matching child objects properties.

Parameters:attrs (dict) – tmux properties to match values of
Returns:
Return type:list