Pane.from_env
Return the pane this process is running inside of.
Source and package
- Qualified name
-
libtmux.Pane. from _env - Module
- libtmux
- Declared in
Pane- Package
- libtmux
- Source
- src/libtmux/pane.py
-
Description#
Reads
TMUXfor the server's socket andTMUX_PANEfor the pane id, then asks tmux for the rest. The stale session id insideTMUXis never consulted, so the answer stays correct after the pane's window has been moved or linked elsewhere.Examples#
>>> socket_path = server.cmd( # doctest: +HIDE... "display-message", "-p", "-t", pane.pane_id, "#{socket_path}"... ).stdout[0]>>> env = { # doctest: +HIDE... "TMUX": f"{socket_path},1,0",... "TMUX_PANE": pane.pane_id,... }>>> Pane.from_env(env)Pane(%1 Window(@1 1:..., Session($1 ...)))>>> Pane.from_env(env).pane_id == pane.pane_idTrueOutside a pane there is nothing to resolve:
>>> from libtmux import exc>>> try:... Pane.from_env({})... except exc.NotInsideTmux as e:... print(e)Not inside a tmux pane: $TMUX is unset or empty- Parameters
- Returns
- Raises
-
-
Not
Inside – WhenTmux TMUXorTMUX_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.
-
Guides#
Pages that discuss from_env.