libtmux Reference MCP Search
On this page

tmux.Server.Sessions

View as Markdown

Module
tmux
Declared in
Server
Package
github.com/libtmux/libtmux-go/tmux
Source
tmux/hierarchy.go
Other languages
PythonTypeScriptRustJava.NETC++Swift
Sessions ( ctx : context.Context ) ([]Session, error)
method [source]
method [source]
Sessions

Sessions materializes the server's sessions. Failures, including ErrNoServer, remain errors rather than empty results.

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.