91 lines
3.1 KiB
Bash
Executable file
91 lines
3.1 KiB
Bash
Executable file
# ------------- Environment Setup -------------
|
|
|
|
# XDG configuration home
|
|
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 pager, editor, and browser
|
|
export PAGER="less -i -N -S -R"
|
|
export EDITOR="nvim"
|
|
export BROWSER="firefox"
|
|
|
|
|
|
# ------------- Platform-Specific Setup -------------
|
|
|
|
# Determine Homebrew prefix based on platform
|
|
case "$(uname -s)" in
|
|
Darwin)
|
|
if [[ -d "/nix/store" ]]; then
|
|
HOMEBREW_PREFIX="/run/current-system/sw" # Darwin with nix
|
|
elif [[ "$(uname -m)" == "arm64" ]]; then
|
|
HOMEBREW_PREFIX="/opt/homebrew" # Apple Silicon
|
|
else
|
|
HOMEBREW_PREFIX="/usr/local" # Intel macOS
|
|
fi
|
|
;;
|
|
*)
|
|
HOMEBREW_PREFIX="/usr/local" # Fallback for other systems
|
|
;;
|
|
esac
|
|
|
|
# Add Homebrew binaries to PATH if they exist
|
|
for dir in "${HOMEBREW_PREFIX}/bin" "${HOMEBREW_PREFIX}/sbin"; do
|
|
[[ -d "$dir" && ! "$PATH" =~ (^|:)$dir(:|$) ]] && export PATH="$dir:$PATH"
|
|
done
|
|
|
|
|
|
# ------------- PATH and Tools Setup -------------
|
|
|
|
# Ensure PYENV_ROOT and MODULAR_HOME are in PATH if set
|
|
[[ -n "$PYENV_ROOT" ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
|
export MODULAR_HOME="$HOME/.modular"
|
|
export PATH="$MODULAR_HOME/pkg/packages.modular.com_mojo:$PATH"
|
|
|
|
# Add ~/.local/bin to PATH if it exists
|
|
[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
|
|
|
|
# Add RVM (Ruby) and Cargo (Rust) binaries to PATH if they exist
|
|
[[ -d "$HOME/.rvm/bin" ]] && export PATH="$PATH:$HOME/.rvm/bin"
|
|
[[ -d "$HOME/.cargo/bin" ]] && export PATH="$HOME/.cargo/bin:$PATH"
|
|
|
|
# Add Go binaries if Go is installed
|
|
if command -v go &> /dev/null; then
|
|
export GOPATH="${GOPATH:-$HOME/.go}"
|
|
export PATH="$PATH:$GOPATH/bin"
|
|
fi
|
|
|
|
# Load nvm if installed
|
|
if [[ -d "$HOME/.nvm" ]]; then
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
|
|
fi
|
|
|
|
# Add coreutils to PATH for macOS if installed via Homebrew
|
|
[[ -d "${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin" ]] && export PATH="${HOMEBREW_PREFIX}/opt/coreutils/libexec/gnubin:$PATH"
|
|
|
|
# Add openssl@1.1 and llvm to PATH if installed (for macOS devs)
|
|
[[ -d "/usr/local/opt/openssl@1.1/bin" ]] && export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
|
|
[[ -d "/usr/local/opt/llvm/bin" ]] && export PATH="/usr/local/opt/llvm/bin:$PATH"
|
|
|
|
# Add BasicTeX binaries for macOS if installed
|
|
[[ -d "/Library/TeX/texbin" ]] && export PATH="/Library/TeX/texbin:$PATH"
|
|
|
|
|
|
# ------------- Conda / Mamba Setup -------------
|
|
|
|
# Configure paths for Conda / Miniforge installations on Apple Silicon
|
|
CONDA_PATHS=("/opt/homebrew/Caskroom/miniforge/base" "/usr/local/Caskroom/miniforge/base")
|
|
for CONDA_PATH in "${CONDA_PATHS[@]}"; do
|
|
if [[ -d "$CONDA_PATH" ]]; then
|
|
[ -f "$CONDA_PATH/etc/profile.d/conda.sh" ] && . "$CONDA_PATH/etc/profile.d/conda.sh"
|
|
[ -f "$CONDA_PATH/etc/profile.d/mamba.sh" ] && . "$CONDA_PATH/etc/profile.d/mamba.sh"
|
|
export PATH="$CONDA_PATH/bin:$PATH"
|
|
break # Stop after the first available path
|
|
fi
|
|
done
|
|
|
|
# Compilation flags (optional)
|
|
# export ARCHFLAGS="-arch x86_64 -arch arm64"
|
|
|