#!/usr/bin/env bash # lib/packages.sh — package installation for macOS (brew) and Linux (apt) install_packages() { local repo_dir="$1" step "Installing packages ($(os_name))" if is_macos; then _install_macos "$repo_dir" elif is_linux; then _install_linux "$repo_dir" else warn "Unknown OS — skipping package installation." fi } _install_macos() { local repo_dir="$1" if ! has_cmd brew; then info "Installing Homebrew..." /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi info "Running brew bundle..." brew bundle --file="$repo_dir/Brewfile" --no-lock success "Homebrew packages installed." } _install_linux() { local repo_dir="$1" info "Updating apt..." sudo apt-get update -qq if [[ -f "$repo_dir/Aptfile" ]]; then info "Installing apt packages from Aptfile..." while IFS= read -r pkg; do [[ -z "$pkg" || "$pkg" == \#* ]] && continue sudo apt-get install -y "$pkg" 2>/dev/null \ && success " apt: $pkg" \ || warn " apt: $pkg not found (may need manual install)" done < "$repo_dir/Aptfile" fi # uv (Python package manager) — not in apt if ! has_cmd uv; then info "Installing uv..." curl -LsSf https://astral.sh/uv/install.sh | sh export PATH="$HOME/.local/bin:$PATH" fi # lsd — modern ls, not in default apt if ! has_cmd lsd; then info "Installing lsd via cargo (or snap)..." if has_cmd snap; then snap install lsd 2>/dev/null; fi fi # lazygit — not in apt if ! has_cmd lazygit; then info "Installing lazygit..." LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/') curl -Lo /tmp/lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" tar xf /tmp/lazygit.tar.gz -C /tmp lazygit sudo install /tmp/lazygit /usr/local/bin rm /tmp/lazygit.tar.gz /tmp/lazygit fi success "Linux packages installed." }