libtmux.Window.from_env
Python
- Python
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust Unavailable
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- libtmux
- Declared in
- Window
- Package
- libtmux
- Source
- src/libtmux/window.py
-
Return the window containing the pane this process runs inside of.
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( # 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,... }>>> 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
-
-
env ( t.Mapping[str, str] | None ) – Environment to read. Defaults to
os.environ.
-
- Returns
- Raises
-
-
NotInsideTmux – When
$TMUXor$TMUX_PANEis unset or malformed. -
TmuxObjectDoesNotExist – When the pane named by
$TMUX_PANEis gone. -
LibTmuxException – When the server named by
$TMUXis unreachable. -
ValueError – When the resolved pane carries no
window_id. Surfaces a clear error underpython -O, where anassertwould be stripped.
-
Discussed in Environment
0 declared, 0 inherited