libtmux Reference MCP Search
On this page

window.navigation.Window.linked_sessions_or_empty

View as Markdown

Module
window.navigation
Declared in
Window
Package
libtmux
Source
crates/libtmux/src/window/navigation.rs
linked_sessions_or_empty ( self ) Vec<Session>
method [source]
method [source]
linked_sessions_or_empty

The sessions this window is linked into, in the order tmux lists them.

A window can be linked into several sessions at once, and every one of them holds the same window rather than a copy. This reports the sessions reaching it, including the one this handle was found through.

The sessions are read from tmux's winlink rows rather than from #{window_linked_sessions_list}, which is a comma-separated list of *names* and so cannot be taken apart: a session named has,comma makes the list a,has,comma, which reads exactly like three sessions.

Empty when the listing fails, which suits a status line. Use Self::linked_sessions when the difference matters.

Examples

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
let first = server.new_session("first").await?;
let second = server.new_session("second").await?;
let window = first.active_window().await?.expect("a window");

assert_eq!(window.linked_sessions_or_empty().await.len(), 1);

window.link_to(&second, None).await?;
let linked = window.linked_sessions_or_empty().await;
assert_eq!(linked.len(), 2, "the same window, reached two ways");

guard.shutdown().await?;

0 declared, 0 inherited

Esc

Type to search.