#!/usr/bin/env bash set -euo pipefail PACKAGES=("zsh" "tmux" "alacritty" "stow") # Detect package manager and install. detect_and_install() { if command -v apt &>/dev/null; then echo "Detected: apt (Debian/Ubuntu)" sudo apt update sudo apt install -y "${PACKAGES[@]}" elif command -v pacman &>/dev/null; then echo "Detected: pacman (Arch)" sudo pacman -Syu --noconfirm "${PACKAGES[@]}" elif command -v dnf &>/dev/null; then echo "Detected: dnf (Fedora/RHEL)" sudo dnf install -y "${PACKAGES[@]}" elif command -v zypper &>/dev/null; then echo "Detected: zypper (openSUSE)" sudo zypper install -y "${PACKAGES[@]}" elif command -v brew &>/dev/null; then echo "Detected: brew (macOS)" brew install "${PACKAGES[@]}" else echo "Error: No supported package manager found" echo "Please install: ${PACKAGES[*]}" exit 1 fi } # Check if all packages are already installed. check_installed() { local missing=() for pkg in "${PACKAGES[@]}"; do if ! command -v "$pkg" &>/dev/null; then missing+=("$pkg") fi done if [[ ${#missing[@]} -gt 0 ]]; then echo "Missing packages: ${missing[*]}" detect_and_install else echo "All required packages already installed." fi } check_installed # Basic setup for this dotfiles repo. mkdir -p "$HOME/.ssh/sockets" echo "Created ~/.ssh/sockets" # Apply all stow packages. cd "$(dirname "$0")" echo "Running: stow -t $HOME */" stow -t "$HOME" */ # Set zsh as default shell. set_default_shell() { local zsh_path zsh_path=$(command -v zsh) read -p "Set zsh as default shell? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then chsh -s "$zsh_path" echo "Default shell changed to: $zsh_path" fi } set_default_shell echo "Bootstrap complete!"