libtmux Reference MCP Search
On this page

libtmux.Server.sessions

View as Markdown

Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
Other languages
TypeScriptRustGoJava.NETC++Swift
sessions ( self ) QueryList[Session]
property [source]
property [source]
sessions

Sessions contained in server.

Can be accessed via .sessions.get() and .sessions.filter()

Returns an empty QueryList when tmux's list-sessions fails for any reason — no running daemon, a missing socket, a permission error, or a subprocess failure. To distinguish "no sessions" from "tmux unreachable", call Server.is_alive or Server.raise_if_dead .

Discussed in Traversal

In other languages List the server’s sessions

Examples

// One invocation, and every collection agrees with the others.
const now = await server.snapshot();
for (const session of now.sessions) console.log(session.name, session.windows.length);
const sessions = await server.sessions();
sessions.where({ name: "work" }).count();
let guard = libtmux::test::TestServer::new().await?;
guard.session("work").await?;

let sessions = guard.server().sessions().await?;
assert_eq!(sessions.len(), 1);
assert!(sessions[0].id().to_string().starts_with('$'));

guard.shutdown().await?;

0 declared, 0 inherited

Esc

Type to search.