#!/usr/bin/env bash set -euo pipefail # ------------------------------ # Common Packages (install these on ALL systems) # ------------------------------ COMMON_PACKAGES=( wget curl git neovim tmux fzf ) # ------------------------------ # Detect Distro # ------------------------------ detect_os() { if [[ -f /etc/os-release ]]; then source /etc/os-release case "$ID" in debian | ubuntu) echo "debian" ;; arch) echo "arch" ;; alpine) echo "alpine" ;; centos | rhel) echo "rhel" ;; fedora) echo "fedora" ;; *) echo "unsupported" ;; esac else echo "unsupported" fi } # ------------------------------ # Installers # ------------------------------ install_packages_debian() { apt update -y apt install -y "${COMMON_PACKAGES[@]}" } install_packages_arch() { pacman -Syu --noconfirm pacman -S --noconfirm "${COMMON_PACKAGES[@]}" } install_packages_alpine() { apk update apk add "${COMMON_PACKAGES[@]}" } install_packages_rhel() { yum install -y "${COMMON_PACKAGES[@]}" } install_packages_fedora() { dnf install -y "${COMMON_PACKAGES[@]}" } # ------------------------------ # LazyVim Installer (Optional) # ------------------------------ install_lazyvim() { if command -v nvim >/dev/null 2>&1; then echo "Installing LazyVim..." git clone https://github.com/LazyVim/starter ~/.config/nvim nvim --headless "+Lazy sync" +qa else echo "Neovim not found, skipping LazyVim install." fi } # ------------------------------ # Main Logic # ------------------------------ main() { OS=$(detect_os) case "$OS" in debian) install_packages_debian ;; arch) install_packages_arch ;; alpine) install_packages_alpine ;; rhel) install_packages_rhel ;; fedora) install_packages_fedora ;; *) echo "Unsupported OS. Exiting." exit 1 ;; esac install_lazyvim echo "✅ Setup complete!" } main "$@"