resolve_ambient_socket_path
Resolve the socket a bare tmux invocation talks to, in tmux's own order.
Source and package
- Qualified name
-
libtmux._internal .env. resolve _ambient _socket _path - Module
- libtmux._internal.env
- Package
- libtmux
- Source
- src/libtmux/_internal/env.py
-
Description
A tmux client given no
-Lor-SprefersTMUX-- the socket of the pane it is running inside -- and only falls back to computing a path underTMUX_TMPDIRwhen there is no pane. Measured against tmux 3.7b: a bare client withTMUXset connects even whenTMUX_TMPDIRnames a directory far too deep to bind, because it never looks there.That order only holds for the bare client. Passing
-Lsends tmux toTMUX_TMPDIRregardless ofTMUX, so a named socket resolves throughresolve_socket_path()instead.- Parameters
- Returns
-
pathlib.PathSocket path a bare tmux client would use.
Examples
>>> from libtmux._internal.env import resolve_ambient_socket_pathInside a pane,
TMUXnames the socket outright:>>> resolve_ambient_socket_path({"TMUX": "/tmp/tmux-1000/default,8421,0"})PosixPath('/tmp/tmux-1000/default')TMUX_TMPDIRis not consulted when there is a pane to inherit from:>>> resolve_ambient_socket_path(... {"TMUX": "/tmp/sock,8421,0", "TMUX_TMPDIR": "/nowhere"}... )PosixPath('/tmp/sock')Outside tmux it falls back to the computed path:
>>> resolve_ambient_socket_path({})PosixPath('/tmp/tmux-.../default')
Recorded calls
source callsThe Python reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux._internal.env.resolve_ambient_socket_path.