@@ -110,6 +110,36 @@ remove_from_rc_if_present() {
110110 fi
111111}
112112
113+ apt_package_installed () {
114+ dpkg -s " $1 " > /dev/null 2>&1
115+ }
116+
117+ install_required_apt_package () {
118+ local pkg=" $1 "
119+
120+ if apt_package_installed " $pkg " ; then
121+ echo " ✅ $pkg already installed"
122+ else
123+ echo " 📦 Installing $pkg ..."
124+ sudo apt install -y " $pkg "
125+ fi
126+ }
127+
128+ install_optional_apt_package () {
129+ local pkg=" $1 "
130+
131+ if apt_package_installed " $pkg " ; then
132+ echo " ✅ $pkg already installed"
133+ else
134+ echo " 📦 Installing $pkg ..."
135+ if sudo apt install -y " $pkg " ; then
136+ echo " ✅ Installed $pkg "
137+ else
138+ echo " ⚠️ $pkg is unavailable from apt on this system; continuing without it"
139+ fi
140+ fi
141+ }
142+
113143# Get the latest nvm tag from GitHub (falls back silently on failure)
114144latest_nvm_tag () {
115145 git ls-remote --tags https://github.com/nvm-sh/nvm.git 2> /dev/null \
@@ -387,17 +417,12 @@ if ! $MINIMAL_MODE && ! $DRY_RUN; then
387417
388418 # Required packages (alphabetical)
389419 for pkg in curl exiv2 fzf gnupg jq nano ripgrep unzip; do
390- echo " 📦 Installing $pkg ..."
391- sudo apt install -y " $pkg "
420+ install_required_apt_package " $pkg "
392421 done
393422
394423 # Best-effort packages: useful enhancements, but not hard blockers
395424 for pkg in bat fd-find git-delta fastfetch zoxide; do
396- if sudo apt install -y " $pkg " ; then
397- echo " 📦 Installed $pkg "
398- else
399- echo " ⚠️ $pkg is unavailable from apt on this system; continuing without it"
400- fi
425+ install_optional_apt_package " $pkg "
401426 done
402427
403428 # gh (GitHub CLI) via official apt repository
@@ -441,10 +466,11 @@ if ! $MINIMAL_MODE && ! $DRY_RUN; then
441466 # fastfetch
442467 if ! command -v fastfetch > /dev/null; then
443468 echo " 📥 Installing fastfetch..."
444- sudo apt install -y fastfetch || {
469+ install_optional_apt_package fastfetch
470+ if ! command -v fastfetch > /dev/null; then
445471 echo " ⚠️ fastfetch not available via apt. You can build it manually:"
446472 echo " https://github.com/fastfetch-cli/fastfetch"
447- }
473+ fi
448474 fi
449475
450476 # handle batcat/bat and fdfind/fd shims
@@ -516,7 +542,7 @@ if ! $MINIMAL_MODE && ! $DRY_RUN; then
516542 if command -v uv > /dev/null 2>&1 ; then
517543 if $INSTALL_ALL || $FORCE_MODE ; then uv_install_py=" y" ; else read -r -p $' 🐍 Install latest Python via uv? [y/N]: ' uv_install_py; fi
518544 if [[ " $uv_install_py " =~ ^[Yy]$ ]]; then
519- uv python install --latest || true
545+ uv python install --default || true
520546 fi
521547 fi
522548
0 commit comments