Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-rs latest

Pane.from_env

Find the pane this process is running in.

Source and package
Qualified name
libtmux::pane::Pane::from_env
Module
pane
Declared in
Pane
Package
libtmux
Source
crates/libtmux/src/pane.rs
pub async fn from_env(server: &crate::Server) -> Result< Option<Self>, Error >

Description#

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());
Parameters

Guides#

Pages that discuss from_env.

Esc

Type to search.

Reference previewOpen reference