API Reference

See also

Quickstart.

Server Object

class libtmux.Server(socket_name=None, socket_path=None, config_file=None, colors=None, **kwargs)

Bases: libtmux.common.TmuxRelationalObject, libtmux.common.EnvironmentMixin

The tmux(1) server.

When instantiated stores information on live, running tmux server.

child_id_attribute = u'session_id'

unique child ID used by TmuxRelationalObject

formatter_prefix = u'server_'

namespace used TmuxMappingObject

socket_name = None

[-L socket-name]

socket_path = None

[-S socket-path]

config_file = None

[-f file]

colors = None

-2 or -8

cmd(*args, **kwargs)

Execute tmux command and return output.

Return type:common.tmux_cmd

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

_list_sessions()

Return list of sessions in dict form.

Retrieved from $ tmux(1) list-sessions stdout.

The list is derived from stdout in common.tmux_cmd which wraps subprocess.Popen.

Return type:list of dict
_sessions

Property / alias to return _list_sessions().

list_sessions()

Return list of Session from the tmux(1) session.

Return type:list of Session
sessions

Property / alias to return list_sessions().

children

Alias sessions for TmuxRelationalObject

_list_windows()

Return list of windows in dict form.

Retrieved from $ tmux(1) list-windows stdout.

The list is derived from stdout in common.tmux_cmd which wraps subprocess.Popen.

Return type:list
_update_windows()

Update internal window data and return self for chainability.

Return type:Server
_list_panes()

Return list of panes in dict form.

Retrieved from $ tmux(1) list-panes stdout.

The list is derived from stdout in util.tmux_cmd which wraps subprocess.Popen.

Return type:list
_update_panes()

Update internal pane data and return self for chainability.

Return type:Server
attached_sessions

Return active Session objects.

This will not work where multiple tmux sessions are attached.

Return type:list of Session
has_session(target_session, exact=True)

Return True if session exists. $ tmux has-session.

Parameters:
  • target_session (str) – session name
  • exact (bool) – match the session name exactly. tmux uses fnmatch by default. Internally prepends = to the session in $ tmux has-session. tmux 2.1 and up only.
Raises:

exc.BadSessionName

Return type:

bool

kill_server()

$ tmux kill-server.

find_where(attrs)

Return object on first match.

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

get_by_id(id)

Return object based on child_id_attribute.

Based on .get() from backbone.js.

Parameters:id (str) –
Return type:object
kill_session(target_session=None)

Kill the tmux session with $ tmux kill-session, return self.

Param:target_session: str. note this accepts fnmatch(3). ‘asdf’ will kill ‘asdfasd’.
Raises:exc.BadSessionName
Return type:Server
remove_environment(name)

Remove environment variable $ tmux set-environment -r <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
set_environment(name, value)

Set environment $ tmux set-environment <name> <value>.

Parameters:
  • name – the environment variable name. such as ‘PATH’.
  • value (str) – environment value.
show_environment(name=None)

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 – the environment variable name. such as ‘PATH’.
unset_environment(name)

Unset environment variable $ tmux set-environment -u <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
where(attrs, first=False)

Return objects matching child objects properties.

Parameters:attrs (dict) – tmux properties to match
Return type:list
switch_client(target_session)

$ tmux switch-client.

Param:target_session: str. name of the session. fnmatch(3) works.
Raises:exc.BadSessionName
attach_session(target_session=None)

$ tmux attach-session aka alias: $ tmux attach.

Param: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, *args, **kwargs)

Return Session from $ tmux new-session.

Uses -P flag to print session info, -F for return formatting returns new Session object.

$ tmux new-session -d will create the session in the background $ tmux new-session -Ad will move to the session name if it already exists. todo: make an option to handle this.

Parameters:
  • session_name (str) –

    session name:

    $ tmux new-session -s <session_name>
    
  • attach (bool) –

    create session in the foreground. attach=False is equivalent to:

    $ tmux new-session -d
    
  • kill_session (bool) – Kill current session if $ tmux has-session Useful for testing workspaces.
  • start_directory (str) – specifies the working directory in which the new session is created.
Raises:

exc.BadSessionName

Return type:

Session

Session Object

class libtmux.Session(server=None, **kwargs)

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

tmux(1) session.

Holds Window objects.

child_id_attribute = u'window_id'

unique child ID key for TmuxRelationalObject

formatter_prefix = u'session_'

namespace used TmuxMappingObject

cmd(*args, **kwargs)

Return server.cmd().

Return type:server.cmd

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

attach_session()

Return $ tmux attach-session aka alias: $ tmux attach.

kill_session()

$ tmux kill-session.

switch_client()

$ tmux switch-client.

Param:target_session: str. note this accepts fnmatch(3).
Raises:exc.LibTmuxException
rename_session(new_name)

Rename session and return new Session object.

Parameters:new_name (str) – new session name
Raises:exc.BadSessionName
Return type:Session
new_window(window_name=None, start_directory=None, attach=True, window_index=u'', window_shell=None)

Return Window from $ 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) – window name.
  • start_directory (str) – specifies the working directory in which the new window is created.
  • attach – 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 – 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.
  • type – bool
Return type:

Window

kill_window(target_window=None)

$ tmux kill-window.

Kill the current window or the window at target-window. removing it from any sessions to which it is linked.

Parameters:target_window (str) – the target window.
_windows

Property / alias to return Session._list_windows().

list_windows()

Return a list of Window from the tmux(1) session.

Return type:Window
windows

Property / alias to return Session.list_windows().

children

Alias windows for TmuxRelationalObject

attached_window

Return active Window object.

Return type:Window
select_window(target_window)

Return Window selected via $ tmux select-window.

Param:window: target_window also ‘last-window’ (-l), ‘next-window’ (-n), or ‘previous-window’ (-p)
Return type:Window
Todo:assure -l, -n, -p work.
attached_pane

Return active Pane object.

set_option(option, value, g=False)

Set option $ tmux set-option <option> <value>.

todo: needs tests

Parameters:
  • option (str) – the window option. such as ‘default-shell’.
  • value (bool) – window value. True/False will turn in ‘on’ and ‘off’. You can also enter ‘on’ or ‘off’ directly.
  • global (bool) – check for option globally across all servers (-g)
Raises:

exc.OptionError, exc.UnknownOption, exc.InvalidOption, exc.AmbiguousOption

show_options(option=None, g=False)

Return a dict of options for the window.

For familiarity with tmux, the option option param forwards to pick a single option, forwarding to Session.show_option().

Parameters:
  • option (str) – optional. show a single option.
  • g (bool) – Pass -g flag for global variable (server-wide)
Return type:

dict

show_option(option, g=False)

Return a list of options for the window.

Todo:

test and return True/False for on/off string

Parameters:
  • option (str) – option to return.
  • global (bool) – check for option globally across all servers (-g)
Return type:

str, int or bool

Raises:

exc.OptionError, exc.UnknownOption, exc.InvalidOption, exc.AmbiguousOption

clear() → None. Remove all items from D.
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.

Based on .get() from backbone.js.

Parameters:id (str) –
Return type:object
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.

remove_environment(name)

Remove environment variable $ tmux set-environment -r <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
set_environment(name, value)

Set environment $ tmux set-environment <name> <value>.

Parameters:
  • name – the environment variable name. such as ‘PATH’.
  • value (str) – environment value.
setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
show_environment(name=None)

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 – the environment variable name. such as ‘PATH’.
unset_environment(name)

Unset environment variable $ tmux set-environment -u <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
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
Return type:list

Window Object

class libtmux.Window(session=None, **kwargs)

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

tmux(1) window.

child_id_attribute = u'pane_id'

unique child ID key for TmuxRelationalObject

formatter_prefix = u'window_'

namespace used TmuxMappingObject

cmd(cmd, *args, **kwargs)

Return Server.cmd() defaulting target_window as target.

Send command to tmux with window_id as target-window.

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

Return type:Server.cmd

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

select_layout(layout=None)

Wrapper for $ tmux select-layout <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).

Parameters:layout (str) – string of the layout, ‘even-horizontal’, ‘tiled’, etc.
set_window_option(option, value)

Wrapper for $ tmux set-window-option <option> <value>.

Parameters:
  • option (str) – option to set, e.g. ‘aggressive-resize’
  • value (bool) – window value. True/False will turn in ‘on’ and ‘off’, also accepts string of ‘on’ or ‘off’ directly.
Raises:

exc.OptionError, exc.UnknownOption, exc.InvalidOption, exc.AmbiguousOption

show_window_options(option=None, g=False)

Return a dict of options for the window.

For familiarity with tmux, the option option param forwards to pick a single option, forwarding to Window.show_window_option().

Parameters:
  • option (str) – optional. show a single option.
  • g (bool) – Pass -g flag for global variable
Return type:

dict

show_window_option(option, g=False)

Return a list of options for the window.

todo: test and return True/False for on/off string

Parameters:
  • option (str) – option to return.
  • g (bool) – Pass -g flag, global.
Return type:

str, int

Raises:

exc.OptionError, exc.UnknownOption, exc.InvalidOption, exc.AmbiguousOption

rename_window(new_name)

Return Window object $ tmux rename-window <new_name>.

Parameters:new_name (str) – name of the window
kill_window()

Kill the current Window object. $ tmux kill-window.

move_window(destination=u'', session=None)

Move the current Window object $ tmux move-window.

Parameters:
  • destination (str) – the target window or index to move the window to, default: empty string
  • session (str) – the target session or index to move the window to, default: current session.
select_window()

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 make w the current window.

Return type:Window
select_pane(target_pane)

Return selected Pane through $ tmux select-pane.

Parameters:target_pane (str) – target_pane, or -U,``-D``, -L, -R or -l.
Return type:Pane
last_pane()

Return last pane.

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

Split window and return the created Pane.

Note

tmux(1) will move window to the new pane if the split-window target is off screen. tmux handles the -d the same way as new-window and attach in Session.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.

Used for splitting window and holding in a python object.

Parameters:
  • attach (bool) – make new window the current window after creating it, default True.
  • start_directory (str) – specifies the working directory in which the new window is created.
  • target (bool) – target_pane to split.
  • vertical (bool) – split vertically
Return type:

Pane

attached_pane

Return the attached Pane.

Return type:Pane
_panes

Property / alias to return _list_panes().

list_panes()

Return list of Pane for the window.

Return type:list of Pane
panes

Property / alias to return list_panes().

children

Alias panes for TmuxRelationalObject

clear() → None. Remove all items from D.
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.

Based on .get() from backbone.js.

Parameters:id (str) –
Return type:object
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
Return type:list

Pane Object

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

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

tmux(1) pane.

Parameters:windowWindow

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

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.

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) – Send enter after sending the input.
  • suppress_history (bool) – Don’t add these keys to the shell history
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) – Attach / select pane after creation.
  • vertical (bool) – split vertically
  • start_directory (str) – specifies the working directory in which the new pane is created.
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) – pane height, 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.
Return type:Pane
enter()

Send carriage return to pane.

$ tmux send-keys send Enter to the pane.

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.

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.

Based on .get() from backbone.js.

Parameters:id (str) –
Return type:object
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
Return type:list

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

Base Class for managing tmux object child entities. .. # NOQA

Manages collection of child objects (a Server has a collection of Session objects, a Session has collection of Window)

Children of TmuxRelationalObject are going to have a self.children, self.child_id_attribute.

Object .children method
Server Server._sessions Server.list_sessions()
Session Session._windows Session.list_windows()
Window Window._panes Window.list_panes()
Pane n/a n/a
Object child_id_attribute value
Server Server.child_id_attribute session_id
Session Session.child_id_attribute window_id
Window Window.child_id_attribute pane_id
Pane n/a n/a
find_where(attrs)

Return object on first match.

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

get_by_id(id)

Return object based on child_id_attribute.

Based on .get() from backbone.js.

Parameters:id (str) –
Return type:object
where(attrs, first=False)

Return objects matching child objects properties.

Parameters:attrs (dict) – tmux properties to match
Return type:list
class libtmux.common.TmuxMappingObject

Base: collections.MutableMapping.

Convenience container. Base class for Pane, Window, Session and Server.

Instance attributes for useful information tmux(1) uses for Session, Window, Pane, stored self._info. For example, a Window will have a window_id and window_name.

Object formatter_prefix value
Server n/a n/a
Session Session.formatter_prefix session_
Window Window.formatter_prefix window_
Pane Pane.formatter_prefix pane_
keys()

Return list of keys.

class libtmux.common.EnvironmentMixin(add_option=None)

Mixin class for managing session and server level environment variables in tmux.

remove_environment(name)

Remove environment variable $ tmux set-environment -r <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
set_environment(name, value)

Set environment $ tmux set-environment <name> <value>.

Parameters:
  • name – the environment variable name. such as ‘PATH’.
  • value (str) – environment value.
show_environment(name=None)

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 – the environment variable name. such as ‘PATH’.
unset_environment(name)

Unset environment variable $ tmux set-environment -u <name>.

Parameters:name – the environment variable name. such as ‘PATH’.
class libtmux.common.tmux_cmd(*args, **kwargs)

tmux(1) command via subprocess.

Parameters:
  • tmux_search_paths (list) – Default PATHs to search tmux for, defaults to default_paths used in which().
  • append_env_path (bool) – Append environment PATHs to tmux search paths.

Usage:

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

Changed in version 0.8: Renamed from tmux to tmux_cmd.

common.which(exe=None, default_paths=['/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin'], append_env_path=True)

Return path of bin. Python clone of /usr/bin/which.

from salt.util - https://www.github.com/saltstack/salt - license apache

Parameters:
  • exe (str) – Application to search PATHs for.
  • default_path (list) – Application to search PATHs for.
  • append_env_path (bool) – Append PATHs in environmental variables.
Return type:

str

common.has_version(version)

Return True if tmux version installed.

Parameters:version (str) – version, ‘1.8’
Returns:True if version matches
Return type:bool
common.has_gt_version(min_version)

Return True if tmux version greater than minimum.

Parameters:min_version (str) – version, e.g. ‘1.8’
Returns:True if version above min_version
Return type:bool
common.has_gte_version(min_version)

Return True if tmux version greater or equal to minimum.

Parameters:min_version (str) – version, e.g. ‘1.8’
Returns:True if version above or equal to min_version
Return type:bool
common.has_lt_version(max_version)

Return True if tmux version less than minimum.

Parameters:max_version (str) – version, e.g. ‘1.8’
Returns:True if version below max_version
Return type:bool
common.has_lte_version(max_version)

Return True if tmux version less or equal to minimum.

Parameters:max_version (str) – version, e.g. ‘1.8’
Returns:True if version below or equal to max_version
Return type:bool
common.has_minimum_version(raises=True)

Return if tmux meets version requirement. Version >1.8 or above.

Parameters:raises (bool) – Will raise exception if version too low, default True
Returns:True if tmux meets minimum required version
Return type:bool

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(error)

Raises exception if error in option command found.

Purpose: As of tmux 2.4, there are now 3 different types of option errors:

  • unknown option
  • invalid option
  • ambiguous option

Before 2.4, unknown option was the user.

All errors raised will have the base error of exc.OptionError. So to catch any option error, use except exc.OptionError.

Parameters:error (str) – error response from subprocess call
Raises:exc.OptionError, exc.UnknownOption, exc.InvalidOption, exc.AmbiguousOption

Exceptions

exception libtmux.exc.LibTmuxException

Base Exception for libtmux Errors.

exception libtmux.exc.TmuxCommandNotFound

Application binary for tmux not found.

exception libtmux.exc.VersionTooLow

Raised if tmux below the minimum version to use libtmux.

exception libtmux.exc.TmuxSessionExists

Session does not exist in the server.

exception libtmux.exc.BadSessionName

Disallowed session name for tmux (empty, contains periods or colons).

exception libtmux.exc.OptionError

Root error for any error involving invalid, ambiguous or bad options.

exception libtmux.exc.UnknownOption

Option unknown to tmux show-option(s) or show-window-option(s).

exception libtmux.exc.InvalidOption

Option invalid to tmux, introduced in tmux v2.4.

exception libtmux.exc.AmbiguousOption

Option that could potentially match more than one.

Test tools

test.get_test_session_name(server, prefix=u'libtmux_')
test.get_test_window_name(session, prefix=u'libtmux_')
test.temp_session(*args, **kwds)

Return a context manager with a temporary session.

e.g.:

with temp_session(server) as session:
    session.new_window(window_name='my window')

The session will destroy itself upon closing with Session. kill_session().

If no session_name is entered, get_test_session_name() will make an unused session name.

Args:Same arguments as Server.new_session()
Yields:Temporary session
Return type:Session
test.temp_window(*args, **kwds)

Return a context manager with a temporary window.

e.g.:

with temp_window(session) as window:
    my_pane = window.split_window()

The window will destroy itself upon closing with window. kill_window().

If no window_name is entered, get_test_window_name() will make an unused window name.

Args:Same arguments as Session.new_window()
Yields:Temporary window
Return type:Window