libtmux Reference MCP Search
On this page

window.Window.from_env

View as Markdown

Module
window
Declared in
Window
Package
libtmux
Source
crates/libtmux/src/window.rs
from_env ( server : &crate::Server ) Result<Option<Self>, Error>
method [source]
method [source]
from_env

Find the window this process is running in.

Resolved through the pane named by TMUX_PANE, which is the only value tmux gives a process that identifies exactly where it is.

Ok(None) means tmux no longer has that pane.

Errors

Returns an error when TMUX_PANE is absent or is not a pane ID, or when the listing fails.

Examples

use libtmux::Window;

let session = server.new_session("locating-window").await?;
let pane = session.panes().await?.remove(0);

// Standing in for the environment tmux gives a process it starts.
let found = Window::from_env_value(server, Some(pane.id().as_ref())).await?;

assert_eq!(found.expect("the window exists").id(), pane.window_id());

Discussed in Environment

0 declared, 0 inherited

Esc

Type to search.