Files
provision/scripts/packages.sh
2025-11-30 14:30:15 -08:00

168 lines
4.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/common.sh"
source "$SCRIPT_DIR/../lib/package.sh"
log_info "Installing packages"
# Essential packages
PACKAGES=(
"git"
"curl"
"wget"
"tmux"
"jq"
"fzf"
"ripgrep"
)
# Modern CLI tools
MODERN_TOOLS=(
"starship"
"zoxide"
"eza"
"fd"
"gh"
)
# Install essential packages
for pkg in "${PACKAGES[@]}"; do
if command_exists "$pkg" || command_exists "${pkg}find" 2>/dev/null; then
log_success "$pkg already installed"
else
log_info "Installing $pkg"
case "$pkg" in
fd)
install_package fd fd-find fd
;;
*)
install_package "$pkg"
;;
esac
fi
done
# Install modern tools
for tool in "${MODERN_TOOLS[@]}"; do
if command_exists "$tool"; then
log_success "$tool already installed"
continue
fi
log_info "Installing $tool"
case "$tool" in
starship)
if is_debian; then
curl -sS https://starship.rs/install.sh | sh -s -- -y
else
install_package starship
fi
;;
zoxide)
if is_debian && ! package_installed zoxide; then
install_cargo zoxide
else
install_package zoxide
fi
;;
eza)
if is_debian && ! package_installed eza; then
if command_exists exa; then
log_success "exa (predecessor) already installed"
else
install_cargo eza
fi
else
install_package eza
fi
;;
gh)
if is_debian && ! package_installed gh; then
maybe_sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | maybe_sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | maybe_sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
update_package_cache
fi
install_package gh gh github-cli
;;
*)
install_package "$tool"
;;
esac
done
# Install X11 utilities (Linux only)
if is_linux; then
# TWM window manager
if command_exists twm; then
log_success "twm already installed"
else
log_info "Installing twm"
install_package twm twm xorg-twm
fi
# slock screen locker
if command_exists slock; then
log_success "slock already installed"
else
log_info "Installing slock"
install_package slock
fi
# xsetroot (in x11-xserver-utils on Debian, xorg-xsetroot on Arch)
if command_exists xsetroot; then
log_success "xsetroot already installed"
else
log_info "Installing xsetroot"
install_package xsetroot x11-xserver-utils xorg-xsetroot
fi
# feh image viewer/wallpaper setter
if command_exists feh; then
log_success "feh already installed"
else
log_info "Installing feh"
install_package feh
fi
# xclock (in x11-apps on Debian, xorg-xclock on Arch)
if command_exists xclock; then
log_success "xclock already installed"
else
log_info "Installing xclock"
install_package xclock x11-apps xorg-xclock
fi
# xload (in x11-apps on Debian, xorg-xload on Arch)
if command_exists xload; then
log_success "xload already installed"
else
log_info "Installing xload"
install_package xload x11-apps xorg-xload
fi
# XDM display manager
if command_exists xdm; then
log_success "xdm already installed"
else
log_info "Installing xdm"
install_package xdm
fi
fi
# Install TPM (Tmux Plugin Manager)
TPM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/plugins/tpm"
if [ ! -d "$TPM_DIR" ]; then
log_info "Installing TPM (Tmux Plugin Manager)"
ensure_dir "$(dirname "$TPM_DIR")"
git clone https://github.com/tmux-plugins/tpm "$TPM_DIR"
log_success "TPM installed"
else
log_success "TPM already installed"
fi
log_success "All packages installed"