Windows#
- class libtmux.Window(session=None, **kwargs)[source]#
Bases:
libtmux.common.TmuxMappingObject
,libtmux.common.TmuxRelationalObject
A tmux(1) Window [window_manual].
Holds
Pane
objects.- Parameters:
session (
Session
) –
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.
- __marker#
- property _info(self, *args)#
- property _panes(self)#
Property / alias to return
_list_panes()
.
- child_id_attribute = pane_id#
- children#
- cmd(self, cmd, *args, **kwargs)[source]#
Return
Server.cmd()
defaultingtarget_window
as target.Send command to tmux with
window_id
astarget-window
.Specifying
('-t', 'custom-target')
or('-tcustom_target')
inargs
will override using the object’swindow_id
as target.- Return type:
Notes
Changed in version 0.8: Renamed from
.tmux
to.cmd
.
- find_where(self, attrs)[source]#
Return object on first match.
Changed in version 0.4: Renamed from
.findWhere
to.find_where
.
- formatter_prefix = window_#
- get(k[, d]) D[k] if k in D, else d. d defaults to None. [source]#
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- get_by_id(self, id)[source]#
Return object based on
child_id_attribute
.Notes
Based on `.get()`_ from `backbone.js`_.
- items() a set-like object providing a view on D's items [source]#
D.items() -> a set-like object providing a view on D’s items
- move_window(self, destination='', session=None)[source]#
Move the current
Window
object$ tmux move-window
.
- property panes(self)#
Property / alias to return
list_panes()
.
- pop(k[, d]) v, remove specified key and return the corresponding value. [source]#
D.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 [source]#
D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
- rename_window(self, new_name: str)[source]#
Return
Window
object$ tmux rename-window <new_name>
.- Parameters:
new_name (str) – name of the window
- select_layout(self, layout=None)[source]#
Wrapper for
$ tmux select-layout <layout>
.- 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).
- select_window(self)[source]#
Select window. Return
self
.To select a window object asynchrously. If a
window
object exists and is no longer longer the current window,w.select_window()
will makew
the current window.- Return type:
- set_window_option(self, option, value)[source]#
Wrapper for
$ tmux set-window-option <option> <value>
.- Parameters:
- Raises:
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D [source]#
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- show_window_option(self, option, g=False)[source]#
Return a list of options for the window.
todo: test and return True/False for on/off string
- Parameters:
- Return type:
- Raises:
- show_window_options(self, option=None, g=False)[source]#
Return a dict of options for the window.
For familiarity with tmux, the option
option
param forwards to pick a single option, forwarding toWindow.show_window_option()
.
- split_window(self, target=None, start_directory=None, attach=True, vertical=True, shell=None, percent=None)[source]#
Split window and return the created
Pane
.Used for splitting window and holding in a python object.
- 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.
target (str) –
target_pane
to split.vertical (str) – split vertically
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.
percent (int, optional) – percentage to occupy with respect to current window
- Return type:
Notes
tmux(1) will move window to the new pane if the
split-window
target is off screen. tmux handles the-d
the same way asnew-window
andattach
inSession.new_window
.By default, this will make the window the pane is created in active. To remain on the same window and split the pane in another target window, pass in
attach=False
.
- update([E, ]**F) None. Update D from mapping/iterable E and F. [source]#
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