70 lines
1.9 KiB
Bash
Executable file
70 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# ------------- Environment Setup -------------
|
|
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 tools
|
|
export PAGER="less -i -N -S -R"
|
|
export EDITOR="nvim"
|
|
export BROWSER="firefox"
|
|
|
|
# ------------- Platform-Specific Setup -------------
|
|
OS_TYPE="$(uname -s)"
|
|
|
|
# Default package manager setup (only for Debian-based systems)
|
|
if [[ "$OS_TYPE" == "Linux" ]]; then
|
|
# Debian/Ubuntu-based systems (and derivatives like WSL Ubuntu)
|
|
if command -v apt &>/dev/null; then
|
|
PACKAGE_MANAGER="apt"
|
|
export PACKAGE_MANAGER
|
|
fi
|
|
fi
|
|
|
|
# ------------- Helper Functions -------------
|
|
safe_path_add() {
|
|
[[ -d "$1" && ":$PATH:" != *":$1:"* ]] && export PATH="$1:$PATH"
|
|
}
|
|
|
|
# ------------- PATH Setup -------------
|
|
safe_path_add "$HOME/.local/bin/scripts"
|
|
|
|
# Python Paths
|
|
[[ -n "$PYENV_ROOT" ]] && safe_path_add "$PYENV_ROOT/bin"
|
|
|
|
# Go Paths
|
|
if command -v go &>/dev/null; then
|
|
export GOPATH="${GOPATH:-$HOME/.go}"
|
|
safe_path_add "$GOPATH/bin"
|
|
fi
|
|
|
|
# Rust
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
|
|
# NVM Setup
|
|
if [[ -d "$HOME/.nvm" ]]; then
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
|
[[ -s "$NVM_DIR/bash_completion" ]] && source "$NVM_DIR/bash_completion"
|
|
fi
|
|
|
|
# ------------- FZF and Nix Setup -------------
|
|
# Determine FZF installation path
|
|
if command -v fzf &>/dev/null; then
|
|
if [[ "$(command -v fzf)" == "/run/current-system/sw/bin/fzf" ]]; then
|
|
FZF_PATH="/run/current-system/sw"
|
|
else
|
|
FZF_PATH=""
|
|
fi
|
|
fi
|
|
|
|
# Add FZF to PATH if not already there
|
|
if [[ -n "$FZF_PATH" && ! "$PATH" =~ (^|:)"$FZF_PATH"(:|$) ]]; then
|
|
export PATH="$FZF_PATH:$PATH"
|
|
fi
|
|
|
|
# Ensure Nix user profile is in PATH (for NixOS users)
|
|
if [[ -d "$HOME/.nix-profile/bin" && ! "$PATH" =~ (^|:)"$HOME/.nix-profile/bin"(:|$) ]]; then
|
|
export PATH="$HOME/.nix-profile/bin:$PATH"
|
|
fi
|