fix(pyenv): preserve shims in login shells

macOS path_helper runs after .zshenv and can move system Python ahead of pyenv. Add an idempotent login hook and preserve it across later easyzsh migrations.
This commit is contained in:
Frank Qing
2026-08-07 18:34:50 +08:00
parent 9257eceb47
commit e41d2b6e93
5 changed files with 54 additions and 7 deletions
+6
View File
@@ -23,5 +23,11 @@ fi
# Always-on fragment: ~/.config/zsh/pyenv.zsh (sourced from ~/.zshenv)
curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s -- zsh/pyenv
# macOS path_helper runs after ~/.zshenv in login shells, so reapply pyenv afterwards.
PYENV_LOGIN_HOOK='[[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/pyenv.zsh" ]] && . "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/pyenv.zsh"'
if ! grep -Fqx "$PYENV_LOGIN_HOOK" "$HOME/.zprofile" 2>/dev/null; then
[[ ! -s "$HOME/.zprofile" ]] || printf '\n' >> "$HOME/.zprofile"
printf '%s\n' "$PYENV_LOGIN_HOOK" >> "$HOME/.zprofile"
fi
# Drop legacy interactive-only copy if present
rm -f "$HOME/.config/zshrc/pyenv.zsh"