#!/usr/bin/env bash # Exit immediately if a command exits with a non-zero status set -e echo "Starting dependency installation..." # Define the common packages PACKAGES=( "stow" "git" "curl" "wget" "neovim" "tmux" "zsh" "bash" "starship" "alacritty" "kitty" # "picom" # "polybar" # "rofi" # "awesome" # "wezterm" # "geany" ) # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } # Determine the OS and package manager if [ "$(uname)" == "Darwin" ]; then echo "Detected macOS" if ! command_exists brew; then echo "Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi echo "Updating Homebrew..." brew update echo "Installing packages via Homebrew..." for pkg in "${PACKAGES[@]}"; do brew install "$pkg" || echo "Failed to install $pkg (or already installed)" done elif [ "$(uname)" == "Linux" ]; then echo "Detected Linux" if command_exists apt-get; then echo "Detected Debian/Ubuntu base" echo "Updating apt..." sudo apt-get update echo "Installing packages via apt..." for pkg in "${PACKAGES[@]}"; do # Note: Package names might differ slightly on apt (e.g., neovim vs nvim). # This script uses common names, but some manual adjustment may be needed. sudo apt-get install -y "$pkg" || echo "Failed to install $pkg (or not found in apt)" done # Starship CLI usually has its own install script on Linux if not in apt if ! command_exists starship; then echo "Installing starship via official script..." curl -sS https://starship.rs/install.sh | sh -s -- -y fi elif command_exists pacman; then echo "Detected Arch Linux base" echo "Updating pacman..." sudo pacman -Syu --noconfirm echo "Installing packages via pacman..." for pkg in "${PACKAGES[@]}"; do sudo pacman -S --noconfirm "$pkg" || echo "Failed to install $pkg (or not found in pacman)" done elif command_exists dnf; then echo "Detected Fedora/RHEL base" echo "Updating dnf..." sudo dnf check-update || true echo "Installing packages via dnf..." for pkg in "${PACKAGES[@]}"; do sudo dnf install -y "$pkg" || echo "Failed to install $pkg (or not found in dnf)" done else echo "Unsupported Linux package manager. Please install dependencies manually:" echo "${PACKAGES[*]}" exit 1 fi else echo "Unsupported Operating System: $(uname)" exit 1 fi echo "Dependency installation complete!"