# ~/.zshenv - Sourced for ALL shell types (interactive, non-interactive, login, non-login)
# Keep this file lightweight - it runs for every shell invocation

# Homebrew - Initialize early for all shell types
eval "$(/opt/homebrew/bin/brew shellenv)"

# Essential PATH entries (needed for all shells including Claude Code)
export PATH="$HOME/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"

# NVM (minimal setup for non-interactive shells)
export NVM_DIR="$HOME/.nvm"
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
  \. "$NVM_DIR/nvm.sh" --no-use 2>/dev/null
  # Put default node in PATH for non-interactive shells (e.g. Claude Code, scripts)
  local default_node="$NVM_DIR/alias/default"
  [[ -r "$default_node" ]] && export PATH="$NVM_DIR/versions/node/$(cat "$default_node")/bin:$PATH"
fi

# pyenv
if command -v pyenv 1>/dev/null 2>&1; then
  export PYENV_ROOT="$HOME/.pyenv"
  export PATH="$PYENV_ROOT/bin:$PATH"
  # Clear a stale rehash temp file left behind by a killed pyenv-rehash.
  # A real rehash completes in well under a second; anything older than a minute is stale.
  find "$PYENV_ROOT/shims/.pyenv-shim" -mmin +1 -delete 2>/dev/null
  eval "$(pyenv init -)"
fi
