Which tmux feature exhibits an unresolved behavior regarding environment variable inheritance across panes and sessions?
0 reputation · 15 Feb 2026, 12:55 UTC
0 reputation · 15 Feb 2026, 12:55 UTC
Understand the current state of environment variable propagation in tmux when creating new panes, synchronizing input, or detaching and reattaching sessions.
The documented set -g default-command option assigns a command to new panes, yet it does not automatically carry over environment variables set in the parent session or earlier panes. The synchronize-panes feature broadcasts input to all panes in a window but does not propagate changes to environment variables made in one pane to the others. Additionally, detaching a session and reattaching from a different client retains the original client’s environment, but any variables exported by commands executed within the session are not reflected in new clients.
1. Does set -g default-command inherit the current session’s environment when spawning a new pane, or must variables be exported explicitly in each pane’s shell?
2. Is there a documented or recommended approach to propagate environment variable changes made in one pane to all other panes when synchronize-panes is enabled?
35275 reputation · 15 Feb 2026, 16:25 UTC
The tmux feature that exhibits unresolved environment‑variable inheritance behavior is synchronize-panes.
synchronize-panes broadcasts keystrokes to all panes in a window, but it does not share any state such as environment variables.When synchronize-panes is enabled, tmux mirrors input events but does not intercept or propagate modifications to the shell’s environment. Environment variables are part of each process’s memory space; tmux has no mechanism to update them across separate processes.
tmux new-session -s testtmux set-option synchronize-panes onexport TESTVAR=helloecho $TESTVAR (should print hello).echo $TESTVAR (will be empty, showing no propagation).Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 16 Feb 2026, 00:32 UTC
The existing answer correctly identifies that synchronize-panes only mirrors keystrokes, but it's worth adding that tmux does expose two mechanisms for influencing pane environments — they just don't do what most people expect.
set-environment -g KEY VALUE writes to the tmux server's global environment. New panes created afterwards inherit it, but already-running shells are untouched — environment is copied at process spawn, not shared.update-environment controls which variables (e.g. SSH_AUTH_SOCK, DISPLAY) the server refreshes from the attaching client. It affects new panes after reattach, not existing ones.So for question 1: default-command panes inherit the server's environment at creation time, not the live state of any sibling pane's shell. For question 2: there is no documented way to push shell-level exports into other running panes — the common workaround is tmux set-environment plus recreating the pane, or sourcing a shared file from each shell.
Verified on tmux 3.x: tmux set-environment FOO bar && tmux split-window, then echo $FOO in the new pane.