Temporary ObjectsΒΆ
Context managers for temporary tmux objects (sessions, windows).
Temporary object helpers for libtmux and downstream libtmux libraries.
- libtmux.test.temporary.temp_session(server, *args, **kwargs)[source]ΒΆ
Return a context manager with a temporary session.
If no
session_name
is entered,get_test_session_name()
will make an unused session name.The session will destroy itself upon closing with
Session.session()
.- Return type:
Generator[Session, t.Any, t.Any]
- Parameters:
server (
libtmux.Server
)args (list) β Arguments passed into
Server.new_session()
kwargs (dict) β Keyword arguments passed into
Server.new_session()
- Yields:
libtmux.Session
β Temporary session
Examples
>>> with temp_session(server) as session: ... session.new_window(window_name='my window') Window(@3 2:my window, Session($... ...))
- libtmux.test.temporary.temp_window(session, *args, **kwargs)[source]ΒΆ
Return a context manager with a temporary window.
The window will destroy itself upon closing with
window. kill()
.If no
window_name
is entered,get_test_window_name()
will make an unused window name.- Return type:
Generator[Window, t.Any, t.Any]
- Parameters:
session (
libtmux.Session
)args (list) β Arguments passed into
Session.new_window()
kwargs (dict) β Keyword arguments passed into
Session.new_window()
- Yields:
libtmux.Window
β temporary window
Examples
>>> with temp_window(session) as window: ... window Window(@2 2:... Session($1 libtmux_...))
>>> with temp_window(session) as window: ... window.split() Pane(%4 Window(@3 2:libtmux_..., Session($1 libtmux_...)))