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 latest

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
Perl Erlang PowerShell Julia Elixir Haskell Common Lisp Ruby Lua TypeScriptRust Go Java C# C++ Swift Kotlin Scala OCaml F# Clojure
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( # 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_id
True
>>> Session.from_env(env)
Session($1 ...)
Parameters
Returns

Session

Raises

Guides#

Pages that discuss from_env.

In other ports#

The session this process is running inside

Equivalents of The session this process is running inside in other languages
Language Equivalent
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript session.Session.fromEnv
Rust session.Session.from_env
Go no equivalent on Session
Java no equivalent on Session
C# LibTmux.Session.FromEnvironmentAsync
C++ no equivalent on Session
Swift no equivalent on Session
OCaml No direct public OCaml equivalent is recorded for this operation.
Perl No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands.

No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Esc

Type to search.

Reference previewOpen reference