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.

MoreLess about this notice

function libtmux

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
resolve_ambient_socket_path ( env: t.Mapping[str, str] | None = None, ) → pathlib.Path

Description

A tmux client given no -L or -S prefers TMUX -- the socket of the pane it is running inside -- and only falls back to computing a path under TMUX_TMPDIR when there is no pane. Measured against tmux 3.7b: a bare client with TMUX set connects even when TMUX_TMPDIR names a directory far too deep to bind, because it never looks there.

That order only holds for the bare client. Passing -L sends tmux to TMUX_TMPDIR regardless of TMUX, so a named socket resolves through resolve_socket_path() instead.

Parameters
Returns

pathlib.Path Socket path a bare tmux client would use.

Examples

>>> from libtmux._internal.env import resolve_ambient_socket_path

Inside a pane, TMUX names the socket outright:

>>> resolve_ambient_socket_path({"TMUX": "/tmp/tmux-1000/default,8421,0"})
PosixPath('/tmp/tmux-1000/default')

TMUX_TMPDIR is 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 calls
No call edges in the Python model.

The 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.

Esc
Search in

Type to search.

Reference previewOpen reference