Session.from_env
Return the session this process's pane belongs to.
Source and package
- Qualified name
-
libtmux.Session .from _env - Module
- libtmux
- Declared in
- Session
- Package
- libtmux
- Source
- src/libtmux/session.py
- Other languages
- PowerShell Julia Ruby Lua TypeScriptRust Go Java C# C++ Swift Kotlin Scala F#
-
Description#
The session id baked into
$TMUXis frozen at pane spawn and goes stale the moment the pane's window is moved or linked elsewhere, so it is never read. tmux is asked instead: the pane row thatPane.from_envfetches is stamped with the session tmux considers canonical for that pane's window.Examples#
>>> socket_path = server.cmd(... "display-message", "-p", "-t", pane.pane_id, "#{socket_path}"... ).stdout[0]Even a deliberately wrong session id in
$TMUXcannot 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 ...)- Parameters
- Returns
- Raises
-
-
Not
Inside – WhenTmux $TMUXor$TMUX_PANEis unset or malformed. -
Tmux
Object – When the pane named byDoes Not Exist $TMUX_PANEis gone. -
Lib
Tmux – When the server named byException $TMUXis unreachable. -
Value
Error – When the resolved pane carries nosession_id. Surfaces a clear error underpython -O, where anassertwould be stripped.
-
Discussed in Environment
In other ports The session this process is running inside
- PowerShell No source-verified PowerShell equivalent is recorded for this operation.
- Julia No source-verified Julia equivalent is recorded for this operation.
- Ruby No source-verified Ruby equivalent is recorded for this operation.
- Lua No source-verified Lua equivalent is recorded for this operation.
- TypeScript
- Rust
- Go no equivalent on
Session - Java no equivalent on
Session - C#
- C++ no equivalent on
Session - Swift no equivalent on
Session - Kotlin No source-verified Kotlin equivalent is recorded for this operation.
- Scala No source-verified Scala equivalent is recorded for this operation.
- F# No source-verified F# equivalent is recorded for this operation.