#!/bin/bash if command -v paccache &>/dev/null; then echo "Trimming pacman package cache..." sudo paccache -rk2 sudo paccache -ruk0 fi # Report packages that were installed as dependencies and are no longer needed. # Not removed automatically: some may be tools you use directly. ORPHANS="$(pacman -Qtdq 2>/dev/null)" if [ -n "$ORPHANS" ]; then echo "Packages no longer needed by anything:" echo "$ORPHANS" | sed 's/^/ /' echo "To remove them: sudo pacman -Rns \$(pacman -Qtdq)" fi