Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Python API

Python documentation

View as Markdown

Module
libtmux
Package
libtmux
Source
src/libtmux/window.py
Other languages
RubyLuaTypeScriptRustGoJava.NETC++Swift
class libtmux.Window
class [source]
class [source]
class libtmux.Window

tmux(1) Window [window_manual].

Holds Pane objects.

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.

Discussed in Workspaces · Build a workspace from a file · Python workspace internal API · Context managers

In other ports A tmux window

Examples

>>> window = session.new_window('My project', attach=True)
>>> window
Window(@2 2:My project, Session($... ...))

Windows have panes:

>>> window.panes
[Pane(...)]
>>> window.active_pane
Pane(...)

Relations moving up:

>>> window.session
Session(...)
>>> window.window_id == session.active_window.window_id
True
>>> window == session.active_window
True
>>> window in session.windows
True

The window can be used as a context manager to ensure proper cleanup:

>>> with session.new_window() as window:
... pane = window.split()
... # Do work with the pane
... # Window will be killed automatically when exiting the context
use libtmux::SplitDirection;
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("work").await?;
let window = session.active_window().await?.expect("a session has a window");
// Splitting is detached by default, so focus stays where it was.
window.split(SplitDirection::Below).await?;
assert_eq!(window.panes().await?.len(), 2);
guard.shutdown().await?;

56 declared, 198 inherited

Members

Inherited members

Reached through libtmux.options.OptionsMixin, libtmux.hooks.HooksMixin, libtmux.neo.Obj.

Esc

Type to search.