Repository navigation
Description
Observed
A zsh user whose ~/.zshenv itself exports ZDOTDIR (the common
export ZDOTDIR=$HOME/.config/zsh pattern) gets no shell integration in a
TermHerd zsh session when TermHerd was started from an environment that never
ran their shell: the Dock, Finder, a desktop launcher. The session emits no
OSC 133 prompt marks and no OSC 7 directory, so its status falls back on the
foreground process (macOS, Linux) and its working directory is not tracked.
Their own configuration does load; only TermHerd's hooks are missing.
Why
crates/pty/src/integration.rs points ZDOTDIR at a private per-session
directory whose .zshenv, .zprofile, .zshrc and .zlogin each source the
user's file of the same name, and whose .zshrc then installs the hooks. With
no ZDOTDIR in the inherited environment, the replay home is $HOME:
- zsh reads the private
.zshenv, which sources~/.zshenv; ~/.zshenvsetsZDOTDIR=~/.config/zsh;- zsh evaluates
$ZDOTDIRagain for each later startup file, so it reads
~/.config/zsh/.zprofileand~/.config/zsh/.zshrc— the user's — and
never the private.zshrcthat holds the hooks.
A ZDOTDIR already present in the inherited environment works: the replay
home is that directory, the user's .zshenv there does not move ZDOTDIR
again (in the common setup), and the private .zshrc runs.
Reproduced
With zsh 5.9 (Ubuntu package, under WSL) and hand-written files of the
generated shape:
case A: ZDOTDIR exported in ~/.zshenv, nothing inherited
user-zshrc
ZDOTDIR=/tmp/…/.config/zsh # hooks never installed
case B: ZDOTDIR inherited, replayed from it
user-zshrc
HOOKS-INSTALLED
ZDOTDIR=/tmp/…/termherd-shell-1
Not reproduced in a live TermHerd session on macOS or Linux.
Expected
The hooks install whatever the user's .zshenv does to ZDOTDIR, and the
user's own files still load.
Possible direction (a guess)
The private .zshenv could, after sourcing the user's file, record the
ZDOTDIR it set (as the new replay home for the remaining files) and restore
ZDOTDIR to the private directory, so zsh keeps reading the generated
.zprofile / .zshrc / .zlogin, which would then replay from the recorded
directory rather than from a path fixed at generation time. That replay path
would have to be computed at shell start rather than baked in.
Documented
The book's Environment variables page (docs/src/reference/environment.md,
section TERMHERD_ORIG_ZDOTDIR) describes the limitation and the workaround:
start TermHerd from a terminal whose shell exported ZDOTDIR. It should be
updated when this is fixed. Found while writing that page (#567).
Activity
docs: wrap the book reference pages — zsh exception, README pointers,…