134 lines
4.6 KiB
Bash
Executable File
134 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Get script directory
|
|
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$DOTFILES_DIR"
|
|
|
|
# Detect OS
|
|
OS=$(uname -s)
|
|
|
|
echo "═══════════════════════════════════════"
|
|
echo " Dotfiles Installation"
|
|
echo " OS: $OS"
|
|
echo "═══════════════════════════════════════"
|
|
echo
|
|
|
|
# ---------------------------------------------------------
|
|
# 1. OS-Specific Package Installation
|
|
# ---------------------------------------------------------
|
|
if [ "$OS" = "Darwin" ]; then
|
|
echo "🍎 Detected macOS."
|
|
|
|
# Install Homebrew if not found
|
|
if ! command -v brew &> /dev/null; then
|
|
echo "Installing Homebrew..."
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
|
|
# Add brew to path for the remainder of this script
|
|
if [ -x "/opt/homebrew/bin/brew" ]; then
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
fi
|
|
fi
|
|
|
|
echo "Installing packages via Homebrew..."
|
|
brew bundle --file="$DOTFILES_DIR/os/macos/Brewfile"
|
|
|
|
elif [ "$OS" = "Linux" ]; then
|
|
echo "🐧 Detected Linux (Assuming CachyOS / Arch)."
|
|
|
|
echo "Updating system and installing official packages..."
|
|
sudo pacman -Syu --noconfirm
|
|
sudo pacman -S --needed --noconfirm - < "$DOTFILES_DIR/os/cachyos/pkglist.txt"
|
|
|
|
# Check for AUR helper and install AUR packages
|
|
AUR_HELPER=""
|
|
if command -v paru &> /dev/null; then
|
|
AUR_HELPER="paru"
|
|
elif command -v yay &> /dev/null; then
|
|
AUR_HELPER="yay"
|
|
fi
|
|
|
|
if [ -n "$AUR_HELPER" ]; then
|
|
echo "Installing AUR packages using $AUR_HELPER..."
|
|
$AUR_HELPER -S --needed --noconfirm - < "$DOTFILES_DIR/os/cachyos/aurlist.txt"
|
|
else
|
|
echo "⚠️ No AUR helper (paru/yay) found. Skipping AUR packages."
|
|
echo "Please install paru or yay and run: paru -S --needed - < os/cachyos/aurlist.txt"
|
|
fi
|
|
|
|
if [ -f "$DOTFILES_DIR/os/cachyos/kde/cachyos-profile.knsv" ] && command -v konsave &> /dev/null; then
|
|
echo "Applying KDE Plasma Profile..."
|
|
konsave -i "$DOTFILES_DIR/os/cachyos/kde/cachyos-profile.knsv" || true
|
|
sleep 2
|
|
konsave -a cachyos-profile || true
|
|
fi
|
|
else
|
|
echo "⚠️ Unsupported OS detected: $OS"
|
|
exit 1
|
|
fi
|
|
|
|
echo
|
|
|
|
# ---------------------------------------------------------
|
|
# 2. Linking Configuration Files
|
|
# ---------------------------------------------------------
|
|
echo "🔗 Setting up configuration..."
|
|
mkdir -p ~/.config
|
|
|
|
cd "$DOTFILES_DIR/stow"
|
|
for app in */; do
|
|
echo "Stowing ${app%/}"
|
|
stow -R "${app%/}" -t "$HOME"
|
|
done
|
|
cd "$DOTFILES_DIR"
|
|
|
|
# Link OS-specific .zprofile and aliases
|
|
if [ "$OS" = "Darwin" ]; then
|
|
echo "Linking macOS .zprofile and aliases..."
|
|
rm -f ~/.zprofile
|
|
ln -s "$DOTFILES_DIR/os/macos/.zprofile" ~/.zprofile
|
|
rm -f ~/.os_aliases
|
|
ln -s "$DOTFILES_DIR/os/macos/aliases.sh" ~/.os_aliases
|
|
elif [ "$OS" = "Linux" ]; then
|
|
echo "Linking Linux .zprofile and aliases..."
|
|
rm -f ~/.zprofile
|
|
ln -s "$DOTFILES_DIR/os/cachyos/.zprofile" ~/.zprofile
|
|
rm -f ~/.os_aliases
|
|
ln -s "$DOTFILES_DIR/os/cachyos/aliases.sh" ~/.os_aliases
|
|
fi
|
|
|
|
echo "Linking common aliases..."
|
|
rm -f ~/.common_aliases
|
|
ln -s "$DOTFILES_DIR/shell/aliases.sh" ~/.common_aliases
|
|
|
|
# ---------------------------------------------------------
|
|
# 3. Tmux Plugin Manager
|
|
# ---------------------------------------------------------
|
|
if [ ! -d ~/.tmux/plugins/tpm ]; then
|
|
echo "Installing tmux plugin manager (TPM)..."
|
|
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
fi
|
|
|
|
# ---------------------------------------------------------
|
|
# 4. Secondary Setup Scripts
|
|
# ---------------------------------------------------------
|
|
echo
|
|
echo "🛠️ Running secondary installation scripts..."
|
|
|
|
# Export newly installed binaries into PATH for these scripts
|
|
export PATH="/opt/homebrew/bin:$HOME/.local/bin:$HOME/go/bin:$HOME/.bun/bin:$PATH"
|
|
|
|
if [ -f "$DOTFILES_DIR/scripts/install_dev_tools.sh" ]; then
|
|
bash "$DOTFILES_DIR/scripts/install_dev_tools.sh"
|
|
fi
|
|
|
|
if [ -f "$DOTFILES_DIR/scripts/install_conda.sh" ]; then
|
|
bash "$DOTFILES_DIR/scripts/install_conda.sh"
|
|
fi
|
|
|
|
echo
|
|
echo "═══════════════════════════════════════"
|
|
echo " ✅ Installation Complete!"
|
|
echo "═══════════════════════════════════════"
|
|
echo "Please restart your terminal or run 'exec zsh' to apply all changes."
|