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/session.py
Other languages
RubyLuaTypeScriptRustGoJava.NETC++Swift
class libtmux.Session
class [source]
class [source]
class libtmux.Session

tmux(1) Session [session_manual].

Holds Window objects.

References

[session_manual]

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.

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

In other ports A tmux session

Examples

>>> session
Session($1 ...)
>>> session.windows
[Window(@1 ...:..., Session($1 ...)]
>>> session.active_window
Window(@1 ...:..., Session($1 ...))
>>> session.active_pane
Pane(%1 Window(@1 ...:..., Session($1 ...)))

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

>>> with server.new_session() as session:
... window = session.new_window()
... # Do work with the window
... # Session will be killed automatically when exiting the context
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("work").await?;
// The name is read from the snapshot this handle owns, so it costs
// nothing; asking tmux for the windows is `async` because it does.
assert_eq!(session.name().to_string_lossy(), "work");
assert_eq!(session.windows().await?.len(), 1);
guard.shutdown().await?;

44 declared, 204 inherited

Members

Inherited members

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

Esc

Type to search.