# Homebrew on macOS. .zshenv runs for every zsh (interactive, scripts, GUI-launched),
# and brew shellenv needs a readable CWD: cd to a safe dir first so launching from a
# TCC-protected directory (e.g. ~/Documents) does not break the eval or prompt for access.
if [ -x /opt/homebrew/bin/brew ]; then
    eval "$(cd /tmp && /opt/homebrew/bin/brew shellenv)"
elif [ -x /usr/local/bin/brew ]; then
    eval "$(cd /tmp && /usr/local/bin/brew shellenv)"
fi

# User-local binaries (pipx, uv tools, grok CLI, etc.).
# Lives here rather than .zshrc/.zprofile so non-interactive agent shells
# (Codex, Claude Code, CI zsh -c) still resolve user-installed tools.
if [ -d "$HOME/.local/bin" ]; then
    case ":${PATH}:" in
        *":$HOME/.local/bin:"*) ;;
        *) PATH="$HOME/.local/bin:${PATH}" ;;
    esac
    export PATH
fi

# Machine-local early env (cargo, private PATH bits). Survives easyzsh reinstalls
# of this file. Prefer this over editing ~/.zshenv by hand.
if [ -f "$HOME/.config/zshenv.local" ]; then
    # shellcheck disable=SC1090,SC1091
    . "$HOME/.config/zshenv.local"
fi
