Window.from_env
Return the window containing the pane this process runs inside of.
Source and package
- Qualified name
-
libtmux.Window .from _env - Module
- libtmux
- Declared in
- Window
- Package
- libtmux
- Source
- src/libtmux/window.py
-
Description#
Resolves through
Pane.from_env, so the answer is the window that contains the caller -- not the session's currently active window, which may be a different one entirely.Examples#
>>> socket_path = server.cmd(... "display-message", "-p", "-t", pane.pane_id, "#{socket_path}"... ).stdout[0]>>> env = {"TMUX": f"{socket_path},1,0", "TMUX_PANE": pane.pane_id}>>> Window.from_env(env)Window(@1 1:..., Session($1 ...))The caller's window is reported even while another window is active:
>>> _ = session.new_window(window_name="foreground", attach=True)>>> Window.from_env(env).window_id == window.window_idTrue- 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 nowindow_id. Surfaces a clear error underpython -O, where anassertwould be stripped.
-
Discussed in Environment