Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Python API

method libtmux stable

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#
from_env ( cls, env: t.Mapping[str, str] | None = None ) → Session

Description#

The session id baked into $TMUX is 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 that Pane.from_env fetches 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 $TMUX cannot mislead it:

>>> env = {"TMUX": f"{socket_path},1,999", "TMUX_PANE": pane.pane_id}
>>> Session.from_env(env).session_id == session.session_id
True
>>> Session.from_env(env)
Session($1 ...)
Parameters
Returns

Session

Raises

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.
Esc

Type to search.

Reference preview Open reference