# Read by EVERY zsh, including non-interactive ones (scripts, `ssh host cmd`).
# Keep it cheap: no subshells in the hot path, no vault lookups, no network.

export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
: ${DOTFILES_HOST:=${(L)${HOST:-$(uname -n)}}}   # lowercased; SCTFW004 -> sctfw004
export DOTFILES_HOST

export EDITOR="nvim"
export BROWSER="qutebrowser"
export GTK_THEME="Arc:dark"
export XDG_DOWNLOAD_DIR="$HOME/downloads"
export QUTEWAL_DYNAMIC_LOADING=True
export NEOVIDE_FORK=1
export RUSTFLAGS="-L/usr/local/lib"

# `col -bx` strips the backspace-overstrike bold that otherwise reaches bat as
# literal ^H sequences. MANROFFOPT=-c is required alongside it.
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT="-c"

# NOT $HOME/.local/bin. That used to be a symlink to this repo's scripts/, so
# `go install` wrote 1.6 GB into version control. See README.
export GOPATH="$HOME/.local/share/go"
export ANDROID_HOME="$HOME/Android/Sdk"

# opencode's {env:} interpolation has no fallback syntax: an unset value becomes
# an empty string and every request fails with an opaque URL parse error. Set
# here rather than in .zshrc so non-interactive shells resolve it too.
export LITELLM_BASE="${LITELLM_BASE:-http://127.0.0.1:4000}"

# Repo scripts come first; host-specific ones shadow the shared ones.
# typeset -U keeps the array unique, so a nested shell re-reading this file
# prepends nothing a second time. Without it PATH grows on every subshell.
typeset -U path PATH
path=(
  "$DOTFILES/hosts/$DOTFILES_HOST/bin"
  "$DOTFILES/common/bin"
  "$HOME/.local/bin"
  "$GOPATH/bin"
  "$HOME/.cargo/bin"
  /usr/lib/jvm/default/bin
  $path
)
export PATH

[[ -r "$HOME/.local/share/bob/env/env.sh" ]] && . "$HOME/.local/share/bob/env/env.sh"

for _f in "$DOTFILES/hosts/$DOTFILES_HOST"/zsh/*.zshenv(N); do source "$_f"; done
unset _f

# Untracked, mode 600. See common/zsh/secrets.zsh.example.
[[ -r "$HOME/.secrets.zsh" ]] && source "$HOME/.secrets.zsh"

true
