Orphaned _tide_prompt_* universal variables accumulate when fish is killed without clean exit
Problem
When fish shells are terminated without a clean exit (e.g., SIGHUP from tmux kill-server), the _tide_on_fish_exit cleanup handler never runs. This causes _tide_prompt_$PID universal variables to accumulate indefinitely in ~/.config/fish/fish_variables.
How to reproduce
- Use Tide with tmux-resurrect or tmux-continuum
- Let continuum auto-save/restore over time (or manually
tmux kill-server+ restore) - Check:
set -U --names | string match '_tide_prompt_*' | wc -l
Impact
On my system after months of tmux usage:
- 665 orphaned
_tide_prompt_*variables fish_variablesgrew to 735KB- Prompt rendering broke: content was empty, only connection dots visible
Root cause
tmux kill-server sends SIGHUP. Fish terminates on SIGHUP but does not fire fish_exit event handlers. _tide_on_fish_exit never cleans up the universal variables for that PID.
This is not limited to tmux -- any non-clean fish termination (kill, crash, OOM) will cause the same accumulation.
Proposed fix
Add startup cleanup to _tide_init.fish (runs on every interactive shell start):
for var in (set -U --names | string match '_tide_prompt_*')
set -l pid (string replace '_tide_prompt_' '' $var)
if test "$pid" != "$fish_pid"; and not kill -0 $pid 2>/dev/null
set -e $var
end
end
Uses kill -0 to check if the PID is still alive -- safe for concurrent fish shells and background tmux sessions.
Prior discussion
This was proposed by @IlanCosman in #69 for v5 but never implemented:
"startup check that iterates over all
_tide_promptvariables, checks the PID, and removes any that are dead"
Related: #562 (fish_variables constantly modified), #242 (universal vs global vars), #374 (fish_variables churn)
Cross-reference: Filed tmux-plugins/tmux-resurrect#559 to document the root cause on the tmux side (SIGHUP from tmux kill-server prevents fish_exit handlers from running).
Hey @Marcel-Bich, I've taken a slightly different approach here in my fork, if you'd like to try it out: fisher install plttn/tide@prompt-tmpfile-signal.