session.Session.fromEnv
TypeScript
- Python
- Ruby Unavailable
- Lua Unavailable
- TypeScript
- Rust
- Go Unavailable
- Java Unavailable
- .NET
- C++ Unavailable
- Swift Unavailable
- Module
- session
- Declared in
- Session
- Package
- libtmux
- Source
- packages/libtmux/src/session.ts
- Other languages
- Python Ruby Lua Rust Go Java .NET C++ Swift
-
Resolve the session this process is running inside.
The pane is authoritative:
$TMUX's exported session id goes stale when a pane is moved, so the session is looked up through$TMUX_PANEinstead.Discussed in Environment
In other ports The session this process is running inside
- Python
libtmux.Session.from_env - Ruby No source-verified Ruby equivalent is recorded for this operation.
- Lua No source-verified Lua equivalent is recorded for this operation.
- Rust
session.Session.from_env - Go no equivalent on
Session - Java no equivalent on
Session - .NET
LibTmux.Session.FromEnvironmentAsync - C++ no equivalent on
Session - Swift no equivalent on
Session
- Python
Examples
const current = await Session.fromEnv();current.name;>>> socket_path = server.cmd( # doctest: +HIDE... "display-message", "-p", "-t", pane.pane_id, "#{socket_path}"... ).stdout[0] Even a deliberately wrong session id in $TMUX cannot mislead it:
>>> env = {"TMUX": f"{socket_path},1,999", "TMUX_PANE": pane.pane_id}>>> Session.from_env(env).session_id == session.session_idTrue>>> Session.from_env(env)Session($1 ...)use libtmux::{Pane, Session};
let session = server.new_session("locating-session").await?;let pane = session.panes().await?.remove(0);
// Standing in for the environment tmux gives a process it starts.let found = Session::from_env_value(server, Some(pane.id().as_ref())).await?;
assert_eq!(found.expect("the session exists").id(), session.id());0 declared, 0 inherited