libtmux Reference MCP Search
On this page

pane.Pane.from_env

View as Markdown

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

Find the pane this process is running in.

tmux sets TMUX_PANE in every process it starts, so a program running inside a pane can locate itself without being told which one it is. Pair it with crate::Server::from_env, which reads the server from the same place.

Ok(None) means tmux no longer has that pane, which is possible when the value came from an environment that outlived it.

Errors

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

Examples

use libtmux::Pane;

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

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

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

Discussed in Environment

0 declared, 0 inherited

Esc

Type to search.