82 lines
No EOL
2.6 KiB
Bash
Executable file
82 lines
No EOL
2.6 KiB
Bash
Executable file
#!/usr/bin/env zsh
|
|
# ~/.zshenv - Environment variables and PATH (loaded for all shells)
|
|
|
|
# XDG base directory specification
|
|
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
|
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
|
|
|
# Default programs
|
|
export PAGER="less -i -N -S -R"
|
|
export EDITOR="nvim"
|
|
|
|
# Ensure PATH entries are unique (use zsh's path array)
|
|
typeset -U path
|
|
|
|
# Helper function to safely add directories to PATH
|
|
safe_path_add() {
|
|
[[ -d "$1" ]] || return 0
|
|
(( ${path[(Ie)$1]} )) || path=("$1" $path)
|
|
}
|
|
|
|
# Cache platform detection to avoid repeated uname calls
|
|
export _OS_TYPE="${_OS_TYPE:-$(uname -s)}"
|
|
export _ARCH="${_ARCH:-$(uname -m)}"
|
|
|
|
# Homebrew prefix (cheap detection; no brew invocation)
|
|
if [[ "$_OS_TYPE" == "Darwin" ]]; then
|
|
if [[ -x "/opt/homebrew/bin/brew" ]]; then
|
|
export HOMEBREW_PREFIX="/opt/homebrew"
|
|
elif [[ -x "/usr/local/bin/brew" ]]; then
|
|
export HOMEBREW_PREFIX="/usr/local"
|
|
fi
|
|
fi
|
|
|
|
# Homebrew shellenv (Option A: interactive shells only)
|
|
if [[ -o interactive ]] && [[ -z "$_HOMEBREW_INITIALIZED" ]]; then
|
|
if [[ -n "${HOMEBREW_PREFIX-}" && -x "$HOMEBREW_PREFIX/bin/brew" ]]; then
|
|
eval "$("$HOMEBREW_PREFIX/bin/brew" shellenv)"
|
|
elif command -v brew &>/dev/null; then
|
|
eval "$(brew shellenv)"
|
|
fi
|
|
export _HOMEBREW_INITIALIZED=1
|
|
fi
|
|
|
|
# Set default browser based on platform
|
|
if [[ -z "$BROWSER" ]]; then
|
|
if [[ "$_OS_TYPE" == "Darwin" ]]; then
|
|
if [[ -f "/Applications/Zen.app/Contents/MacOS/zen" ]]; then
|
|
export BROWSER="/Applications/Zen.app/Contents/MacOS/zen"
|
|
elif [[ -f "/Applications/Safari.app/Contents/MacOS/Safari" ]]; then
|
|
export BROWSER="/Applications/Safari.app/Contents/MacOS/Safari"
|
|
fi
|
|
else
|
|
export BROWSER="$(command -v firefox || command -v google-chrome || command -v chromium)"
|
|
fi
|
|
fi
|
|
|
|
# Development tool paths
|
|
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
|
|
export GOPATH="${GOPATH:-$HOME/.go}"
|
|
|
|
# Add user and development tool directories to PATH
|
|
if [[ -n "${HOMEBREW_PREFIX-}" ]]; then
|
|
safe_path_add "$HOMEBREW_PREFIX/bin"
|
|
safe_path_add "$HOMEBREW_PREFIX/sbin"
|
|
fi
|
|
safe_path_add "$HOME/.local/bin"
|
|
safe_path_add "$HOME/.local/bin/scripts"
|
|
safe_path_add "$HOME/.antigravity/antigravity/bin"
|
|
safe_path_add "/Applications/Windsurf.app/Contents/Resources/app/bin"
|
|
safe_path_add "$PYENV_ROOT/bin"
|
|
safe_path_add "$GOPATH/bin"
|
|
|
|
# Detect remote development environments
|
|
if [[ -n "$SSH_CONNECTION" ]]; then
|
|
export IS_REMOTE=1
|
|
fi
|
|
|
|
if [[ -n "$CODESPACES" ]] || [[ -d "/workspaces" ]]; then
|
|
export IS_CODESPACES=1
|
|
safe_path_add "/workspaces/bin"
|
|
fi |