API Reference¶
See also
Server Object¶
-
class
libtmux.Server(socket_name=None, socket_path=None, config_file=None, colors=None, **kwargs)[source]¶ Bases:
libtmux.common.TmuxRelationalObject,libtmux.common.EnvironmentMixinServer._sessions[Session, …]Session._windows[Window, …]Window._panes[Pane, …]
When instantiated stores information on live, running tmux server.
Parameters: References
[2] - CLIENTS AND SESSIONS. openbsd manpage for TMUX(1)
- “The tmux server manages clients, sessions, windows and panes. Clients are attached to sessions to interact with them, either when they are created with the new-session command, or later with the attach-session command. Each session has one or more windows linked into it. Windows may be linked to multiple sessions and are made up of one or more panes, each of which contains a pseudo terminal.”
https://man.openbsd.org/tmux.1#CLIENTS_AND_SESSIONS. Accessed April 1st, 2018.
-
child_id_attribute= 'session_id'¶ unique child ID used by
TmuxRelationalObject
-
formatter_prefix= 'server_'¶ namespace used
TmuxMappingObject
-
socket_name= None¶ [-L socket-name]
-
socket_path= None¶ [-S socket-path]
-
config_file= None¶ [-f file]
-
colors= None¶ -2or-8
-
cmd(*args, **kwargs)[source]¶ Execute tmux command and return output.
Returns: Return type: common.tmux_cmdNotes
Changed in version 0.8: Renamed from
.tmuxto.cmd.
-
_list_sessions()[source]¶ Return list of sessions in
dictform.Retrieved from
$ tmux(1) list-sessionsstdout.The
listis derived fromstdoutincommon.tmux_cmdwhich wrapssubprocess.Popen.Returns: Return type: list of dict
-
property
_sessions¶ Property / alias to return
_list_sessions().
-
list_sessions()[source]¶ Return list of
Sessionfrom thetmux(1)session.Returns: Return type: list of Session
-
property
sessions¶ Property / alias to return
list_sessions().
-
property
children¶ Alias
sessionsforTmuxRelationalObject
-
_list_windows()[source]¶ Return list of windows in
dictform.Retrieved from
$ tmux(1) list-windowsstdout.The
listis derived fromstdoutincommon.tmux_cmdwhich wrapssubprocess.Popen.Returns: Return type: list of dict
-
_update_windows()[source]¶ Update internal window data and return
selffor chainability.Returns: Return type: Server
-
_list_panes()[source]¶ Return list of panes in
dictform.Retrieved from
$ tmux(1) list-panesstdout.The
listis derived fromstdoutinutil.tmux_cmdwhich wrapssubprocess.Popen.Returns: Return type: list
-
_update_panes()[source]¶ Update internal pane data and return
selffor chainability.Returns: Return type: Server
-
property
attached_sessions¶ Return active
Sessionobjects.This will not work where multiple tmux sessions are attached.
Returns: Return type: list of Session
-
has_session(target_session, exact=True)[source]¶ Return True if session exists.
$ tmux has-session.Parameters: Raises: Returns: Return type:
-
find_where(attrs)[source]¶ Return object on first match.
Changed in version 0.4: Renamed from
.findWhereto.find_where.
-
get_by_id(id)[source]¶ Return object based on
child_id_attribute.Parameters: val (str) – Returns: Return type: object Notes
Based on .get() from backbone.js.
-
kill_session(target_session=None)[source]¶ Kill the tmux session with
$ tmux kill-session, returnself.Parameters: target_session (str, optional) – target_session: str. note this accepts fnmatch(3). ‘asdf’ will kill ‘asdfasd’.Returns: Return type: ServerRaises: exc.BadSessionName –
-
remove_environment(name)[source]¶ Remove environment variable
$ tmux set-environment -r <name>.Parameters: name (str) – the environment variable name. such as ‘PATH’.
-
set_environment(name, value)[source]¶ Set environment
$ tmux set-environment <name> <value>.Parameters:
-
show_environment(name=None)[source]¶ Show environment
$ tmux show-environment -t [session] <name>.Return dict of environment variables for the session or the value of a specific variable if the name is specified.
Parameters: name (str) – the environment variable name. such as ‘PATH’. Returns: environmental variables in dict, if no name, or str if name entered. Return type: str or dict
-
unset_environment(name)[source]¶ Unset environment variable
$ tmux set-environment -u <name>.Parameters: name (str) – the environment variable name. such as ‘PATH’.
-
where(attrs, first=False)[source]¶ Return objects matching child objects properties.
Parameters: attrs (dict) – tmux properties to match values of Returns: Return type: list
-
switch_client(target_session)[source]¶ $ tmux switch-client.Parameters: target_session (str) – name of the session. fnmatch(3) works. Raises: exc.BadSessionName –
-
attach_session(target_session=None)[source]¶ $ tmux attach-sessionaka alias:$ tmux attach.Parameters: target_session (str) – name of the session. fnmatch(3) works. Raises: exc.BadSessionName –
-
new_session(session_name=None, kill_session=False, attach=False, start_directory=None, window_name=None, window_command=None, *args, **kwargs)[source]¶ Return
Sessionfrom$ tmux new-session.Uses
-Pflag to print session info,-Ffor return formatting returns new Session object.$ tmux new-session -dwill create the session in the background$ tmux new-session -Adwill move to the session name if it already exists. todo: make an option to handle this.Parameters: Other Parameters: kill_session (bool, optional) – Kill current session if
$ tmux has-session. Useful for testing workspaces.start_directory (str, optional) – specifies the working directory in which the new session is created.
window_name (str, optional) –
$ tmux new-session -n <window_name>
window_command (str) – execute a command on starting the session. The window will close when the command exits. NOTE: When this command exits the window will close. This feature is useful for long-running processes where the closing of the window upon completion is desired.
Returns: Return type: Raises:
Session Object¶
-
class
libtmux.Session(server=None, **kwargs)[source]¶ Bases:
libtmux.common.TmuxMappingObject,libtmux.common.TmuxRelationalObject,libtmux.common.EnvironmentMixinHolds
Windowobjects.Parameters: server ( Server) –References
[3] - tmux session. openbsd manpage for TMUX(1).
“When tmux is started it creates a new session with a single window and displays it on screen…”
“A session is a single collection of pseudo terminals under the management of tmux. Each session has one or more windows linked to it.”
https://man.openbsd.org/tmux.1#DESCRIPTION. Accessed April 1st, 2018.
-
child_id_attribute= 'window_id'¶ unique child ID key for
TmuxRelationalObject
-
formatter_prefix= 'session_'¶ namespace used
TmuxMappingObject
-
cmd(*args, **kwargs)[source]¶ Return
server.cmd().Returns: Return type: server.cmdNotes
Changed in version 0.8: Renamed from
.tmuxto.cmd.
-
switch_client()[source]¶ Switch client to this session.
Raises: exc.LibTmuxException –
-
rename_session(new_name)[source]¶ Rename session and return new
Sessionobject.Parameters: new_name (str) – new session name Returns: Return type: SessionRaises: exc.BadSessionName –
-
new_window(window_name=None, start_directory=None, attach=True, window_index='', window_shell=None)[source]¶ Return
Windowfrom$ tmux new-window.By default, this will make the window active. For the new window to be created and not set to current, pass in
attach=False.Parameters: - window_name (str, optional) –
- start_directory (str, optional) – working directory in which the new window is created.
- attach (bool, optional) – make new window the current window after creating it, default True.
- window_index (str) – create the new window at the given index position. Default is empty string which will create the window in the next available position.
- window_shell (str) –
execute a command on starting the window. The window will close when the command exits.
Note
When this command exits the window will close. This feature is useful for long-running processes where the closing of the window upon completion is desired.
Returns: Return type:
-
kill_window(target_window=None)[source]¶ Close a tmux window, and all panes inside it,
$ tmux kill-windowKill the current window or the window at
target-window. removing it from any sessions to which it is linked.Parameters: target_window (str, optional) – window to kill
-
property
_windows¶ Property / alias to return
Session._list_windows().
-
list_windows()[source]¶ Return a list of
Windowfrom thetmux(1)session.Returns: Return type: Window
-
property
windows¶ Property / alias to return
Session.list_windows().
-
property
children¶ Alias
windowsforTmuxRelationalObject
-
select_window(target_window)[source]¶ Return
Windowselected via$ tmux select-window.Parameters: window (str) – target_windowalso ‘last-window’ (-l), ‘next-window’ (-n), or ‘previous-window’ (-p)Returns: Return type: WindowNotes
-
set_option(option, value, _global=False)[source]¶ Set option
$ tmux set-option <option> <value>.Parameters: Raises: Notes
-
show_options(option=None, _global=False)[source]¶ Return a dict of options for the window.
For familiarity with tmux, the option
optionparam forwards to pick a single option, forwarding toSession.show_option().Parameters: Returns: Return type: Notes
Uses
_globalfor keyword name instead ofglobalto avoid colliding with reserved keyword.
-
show_option(option, _global=False)[source]¶ Return a list of options for the window.
Parameters: Returns: Return type: Raises: Notes
Uses
_globalfor keyword name instead ofglobalto avoid colliding with reserved keyword.Test and return True/False for on/off string.
-
find_where(attrs)[source]¶ Return object on first match.
Changed in version 0.4: Renamed from
.findWhereto.find_where.
-
get_by_id(id)[source]¶ Return object based on
child_id_attribute.Parameters: val (str) – Returns: Return type: object Notes
Based on .get() from backbone.js.
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]¶ 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]¶ as a 2-tuple; but raise KeyError if D is empty.
-
remove_environment(name)[source]¶ Remove environment variable
$ tmux set-environment -r <name>.Parameters: name (str) – the environment variable name. such as ‘PATH’.
-
set_environment(name, value)[source]¶ Set environment
$ tmux set-environment <name> <value>.Parameters:
-
show_environment(name=None)[source]¶ Show environment
$ tmux show-environment -t [session] <name>.Return dict of environment variables for the session or the value of a specific variable if the name is specified.
Parameters: name (str) – the environment variable name. such as ‘PATH’. Returns: environmental variables in dict, if no name, or str if name entered. Return type: str or dict
-
unset_environment(name)[source]¶ Unset environment variable
$ tmux set-environment -u <name>.Parameters: name (str) – the environment variable name. such as ‘PATH’.
Window Object¶
-
class
libtmux.Window(session=None, **kwargs)[source]¶ Bases:
libtmux.common.TmuxMappingObject,libtmux.common.TmuxRelationalObjectHolds
Paneobjects.Parameters: session ( Session) –References
[4] - 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.
-
child_id_attribute= 'pane_id'¶ unique child ID key for
TmuxRelationalObject
-
formatter_prefix= 'window_'¶ namespace used
TmuxMappingObject
-
cmd(cmd, *args, **kwargs)[source]¶ Return
Server.cmd()defaultingtarget_windowas target.Send command to tmux with
window_idastarget-window.Specifying
('-t', 'custom-target')or('-tcustom_target')inargswill override using the object’swindow_idas target.Returns: Return type: Server.cmdNotes
Changed in version 0.8: Renamed from
.tmuxto.cmd.
-
select_layout(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-layoutwith 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]¶ Wrapper for
$ tmux set-window-option <option> <value>.Parameters: Raises:
-
show_window_options(option=None, g=False)[source]¶ Return a dict of options for the window.
For familiarity with tmux, the option
optionparam forwards to pick a single option, forwarding toWindow.show_window_option().Parameters: Returns: Return type:
-
show_window_option(option, g=False)[source]¶ Return a list of options for the window.
todo: test and return True/False for on/off string
Parameters: Returns: Return type: Raises:
-
rename_window(new_name)[source]¶ Return
Windowobject$ tmux rename-window <new_name>.Parameters: new_name (str) – name of the window
-
move_window(destination='', session=None)[source]¶ Move the current
Windowobject$ tmux move-window.Parameters:
-
select_window()[source]¶ Select window. Return
self.To select a window object asynchrously. If a
windowobject exists and is no longer longer the current window,w.select_window()will makewthe current window.Returns: Return type: Window
-
select_pane(target_pane)[source]¶ Return selected
Panethrough$ tmux select-pane.Parameters: target_pane (str) – ‘target_pane’, ‘-U’ ,’-D’, ‘-L’, ‘-R’, or ‘-l’. Returns: Return type: Pane
-
split_window(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_paneto 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
Returns: Return type: Notes
tmux(1) will move window to the new pane if the
split-windowtarget is off screen. tmux handles the-dthe same way asnew-windowandattachinSession.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.
-
property
_panes¶ Property / alias to return
_list_panes().
-
property
panes¶ Property / alias to return
list_panes().
-
property
children¶ Alias
panesforTmuxRelationalObject
-
find_where(attrs)[source]¶ Return object on first match.
Changed in version 0.4: Renamed from
.findWhereto.find_where.
-
get_by_id(id)[source]¶ Return object based on
child_id_attribute.Parameters: val (str) – Returns: Return type: object Notes
Based on .get() from backbone.js.
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]¶ 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]¶ as a 2-tuple; but raise KeyError if D is empty.
Pane Object¶
-
class
libtmux.Pane(window=None, **kwargs)[source]¶ Bases:
libtmux.common.TmuxMappingObject,libtmux.common.TmuxRelationalObjectPaneinstances can send commands directly to a pane, or traverse between linked tmux objects.Parameters: window ( Window) –Notes
Changed in version 0.8: Renamed from
.tmuxto.cmd.References
[5] - 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= 'pane_'¶ namespace used
TmuxMappingObject
-
cmd(cmd, *args, **kwargs)[source]¶ Return
Server.cmd()defaulting totarget_paneas target.Send command to tmux with
pane_idastarget-pane.Specifying
('-t', 'custom-target')or('-tcustom_target')inargswill override using the object’spane_idas target.Returns: Return type: Server.cmd
-
send_keys(cmd, enter=True, suppress_history=True, literal=False)[source]¶ $ tmux send-keysto the pane.A leading space character is added to cmd to avoid polluting the user’s history.
Parameters:
-
display_message(cmd, get_text=False)[source]¶ $ tmux display-messageto the pane.Displays a message in target-client status line.
Parameters: Returns: listNone
-
split_window(attach=False, vertical=True, start_directory=None, percent=None)[source]¶ Split window at pane and return newly created
Pane.Parameters: Returns: Return type:
-
resize_pane(*args, **kwargs)[source]¶ $ tmux resize-paneof pane and returnself.Parameters: target_pane (str) –
target_pane, or-U,``-D``,-L,-R.Other Parameters: - height (int) –
resize-pane -ydimensions - width (int) –
resize-pane -xdimensions
Returns: Return type: Raises: - height (int) –
-
capture_pane()[source]¶ Capture text from pane.
$ tmux capture-paneto pane.Returns: Return type: list
-
select_pane()[source]¶ Select pane. Return
self.To select a window object asynchrously. If a
paneobject exists and is no longer longer the current window,w.select_pane()will makepthe current pane.Returns: Return type: pane
-
find_where(attrs)[source]¶ Return object on first match.
Changed in version 0.4: Renamed from
.findWhereto.find_where.
-
get_by_id(id)[source]¶ Return object based on
child_id_attribute.Parameters: val (str) – Returns: Return type: object Notes
Based on .get() from backbone.js.
-
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]¶ 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]¶ as a 2-tuple; but raise KeyError if D is empty.
Internals¶
-
libtmux.common.TMUX_MIN_VERSION= '1.8'¶ Minimum version of tmux required to run libtmux
-
libtmux.common.TMUX_MAX_VERSION= '2.4'¶ Most recent version of tmux supported
-
class
libtmux.common.TmuxRelationalObject[source]¶ Base Class for managing tmux object child entities. .. # NOQA
Manages collection of child objects (a
Serverhas a collection ofSessionobjects, aSessionhas collection ofWindow)Children of
TmuxRelationalObjectare going to have aself.children,self.child_id_attribute.Object .children method ServerServer._sessionsServer.list_sessions()SessionSession._windowsSession.list_windows()WindowWindow._panesWindow.list_panes()Panen/a n/a Object child_id_attribute value ServerServer.child_id_attributesession_id SessionSession.child_id_attributewindow_id WindowWindow.child_id_attributepane_id Panen/a n/a -
find_where(attrs)[source]¶ Return object on first match.
Changed in version 0.4: Renamed from
.findWhereto.find_where.
-
-
class
libtmux.common.TmuxMappingObject[source]¶ Base:
MutableMapping.Convenience container. Base class for
Pane,Window,SessionandServer.Instance attributes for useful information tmux(1) uses for Session, Window, Pane, stored
self._info. For example, aWindowwill have awindow_idandwindow_name.Object formatter_prefix value Servern/a n/a SessionSession.formatter_prefixsession_ WindowWindow.formatter_prefixwindow_ PanePane.formatter_prefixpane_
-
class
libtmux.common.EnvironmentMixin(add_option=None)[source]¶ Mixin class for managing session and server level environment variables in tmux.
-
remove_environment(name)[source]¶ Remove environment variable
$ tmux set-environment -r <name>.Parameters: name (str) – the environment variable name. such as ‘PATH’.
-
set_environment(name, value)[source]¶ Set environment
$ tmux set-environment <name> <value>.Parameters:
-
show_environment(name=None)[source]¶ Show environment
$ tmux show-environment -t [session] <name>.Return dict of environment variables for the session or the value of a specific variable if the name is specified.
Parameters: name (str) – the environment variable name. such as ‘PATH’. Returns: environmental variables in dict, if no name, or str if name entered. Return type: str or dict
-
-
class
libtmux.common.tmux_cmd(*args, **kwargs)[source]¶ tmux(1) command via
subprocess.Parameters: Examples
proc = tmux_cmd('new-session', '-s%' % 'my session') if proc.stderr: raise exc.LibTmuxException( 'Command: %s returned error: %s' % (proc.cmd, proc.stderr) ) print('tmux command returned %s' % proc.stdout)
Equivalent to:
$ tmux new-session -s my session
Notes
Changed in version 0.8: Renamed from
tmuxtotmux_cmd.
-
common.which(default_paths=['/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], append_env_path=True)[source]¶ Return path of bin. Python clone of /usr/bin/which.
Parameters: Returns: path of application, if found in paths.
Return type: Notes
from salt.util - https://www.github.com/saltstack/salt - license apache
-
common.get_version()[source]¶ Return tmux version.
If tmux is built from git master, the version returned will be the latest version appended with -master, e.g.
2.4-master.If using OpenBSD’s base system tmux, the version will have
-openbsdappended to the latest version, e.g.2.4-openbsd.Returns: tmux version according to libtmux.common.which()’s tmuxReturn type: distutils.version.LooseVersion
-
common.has_version()[source]¶ Return affirmative if tmux version installed.
Parameters: version (str) – version number, e.g. ‘1.8’ Returns: True if version matches Return type: bool
-
common.has_gt_version()[source]¶ Return affirmative if tmux version greater than minimum.
Parameters: min_version (str) – tmux version, e.g. ‘1.8’ Returns: True if version above min_version Return type: bool
-
common.has_gte_version()[source]¶ Return True if tmux version greater or equal to minimum.
Parameters: min_version (str) – tmux version, e.g. ‘1.8’ Returns: True if version above or equal to min_version Return type: bool
-
common.has_lt_version()[source]¶ Return True if tmux version less than minimum.
Parameters: max_version (str) – tmux version, e.g. ‘1.8’ Returns: True if version below max_version Return type: bool
-
common.has_lte_version()[source]¶ Return True if tmux version less or equal to minimum.
Parameters: max_version (str) – tmux version, e.g. ‘1.8’ Returns: True if version below or equal to max_version Return type: bool
-
common.has_minimum_version()[source]¶ Return if tmux meets version requirement. Version >1.8 or above.
Parameters: raises (bool) – raise exception if below minimum version requirement Returns: True if tmux meets minimum required version. Return type: bool Raises: libtmux.exc.VersionTooLow – tmux version below minimum required for libtmux Notes
Changed in version 0.7.0: No longer returns version, returns True or False
Changed in version 0.1.7: Versions will now remove trailing letters per Issue 55.
-
common.handle_option_error()[source]¶ Raises exception if error in option command found.
In tmux 3.0, show-option and show-window-otion return invalid option instead of unknown option. See https://github.com/tmux/tmux/blob/3.0/cmd-show-options.c.
In tmux >2.4, there are 3 different types of option errors:
- unknown option
- invalid option
- ambiguous option
In tmux <2.4, unknown option was the only option.
All errors raised will have the base error of
exc.OptionError. So to catch any option error, useexcept exc.OptionError.Parameters: error (str) – Error response from subprocess call.
Raises:
Exceptions¶
-
exception
libtmux.exc.VersionTooLow[source]¶ Raised if tmux below the minimum version to use libtmux.
-
exception
libtmux.exc.BadSessionName[source]¶ Disallowed session name for tmux (empty, contains periods or colons).
-
exception
libtmux.exc.OptionError[source]¶ Root error for any error involving invalid, ambiguous or bad options.
Test tools¶
-
test.retry()[source]¶ Retry a block of code until a time limit or
break.Parameters: seconds (int) – Seconds to retry, defaults to RETRY_TIMEOUT_SECONDS, which is configurable via environmental variables.Returns: True if time passed since retry() invoked less than seconds param. Return type: bool Examples
>>> while retry(): ... p = w.attached_pane ... p.server._update_panes() ... if p.current_path == pane_path: ... break
-
test.get_test_session_name(prefix='libtmux_')[source]¶ Faker to create a session name that doesn’t exist.
Parameters: - server (
libtmux.Server) – libtmux server - prefix (str) – prefix for sessions (e.g.
libtmux_). Defaults toTEST_SESSION_PREFIX.
Returns: Random session name guaranteed to not collide with current ones.
Return type: - server (
-
test.get_test_window_name(prefix='libtmux_')[source]¶ Faker to create a window name that doesn’t exist.
Parameters: - session (
libtmux.Session) – libtmux session - prefix (str) –
prefix for windows (e.g.
libtmux_). Defaults toTEST_SESSION_PREFIX.ATM we reuse the test session prefix here.
Returns: Random window name guaranteed to not collide with current ones.
Return type: - session (
-
test.temp_session(*args, **kwargs)[source]¶ Return a context manager with a temporary session.
If no
session_nameis entered,get_test_session_name()will make an unused session name.The session will destroy itself upon closing with
Session. kill_session().Parameters: server (
libtmux.Server) –Other Parameters: - args (list) – Arguments passed into
Server.new_session() - kwargs (dict) – Keyword arguments passed into
Server.new_session()
Yields: libtmux.Session– Temporary sessionExamples
>>> with temp_session(server) as session: ... session.new_window(window_name='my window')
- args (list) – Arguments passed into
-
test.temp_window(*args, **kwargs)[source]¶ Return a context manager with a temporary window.
The window will destroy itself upon closing with
window. kill_window().If no
window_nameis entered,get_test_window_name()will make an unused window name.Parameters: session (
libtmux.Session) –Other Parameters: - args (list) – Arguments passed into
Session.new_window() - kwargs (dict) – Keyword arguments passed into
Session.new_window()
Yields: libtmux.Window– temporary windowExamples
>>> with temp_window(session) as window: ... my_pane = window.split_window()
- args (list) – Arguments passed into
-
class
libtmux.test.EnvironmentVarGuard[source]¶ Mock environmental variables safetly.
Helps rotect the environment variable properly. Can be used as context manager.
Notes
Vendorized to fix issue with Anaconda Python 2 not including test module, see #121 [1]
References
[1] Just installed, “ImportError: cannot import name test_support”. GitHub issue for tmuxp. https://github.com/tmux-python/tmuxp/issues/121. Created October 12th, 2015. Accessed April 7th, 2018.
