Skip to content

Instantly share code, notes, and snippets.

@re-xyr
Last active March 10, 2025 14:52
Show Gist options
  • Save re-xyr/efede2d1c36543260192e4e8b17a2fc5 to your computer and use it in GitHub Desktop.
Save re-xyr/efede2d1c36543260192e4e8b17a2fc5 to your computer and use it in GitHub Desktop.
pacman-detect-orphans
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Description = Detecting orphaned packages...
When = PostTransaction
Exec = /usr/local/bin/pacman-detect-orphans
#! /bin/sh
orphans=$(pacman -Qtd)
if [[ -z $orphans ]]; then
echo "==> no orphan packages found"
else
lines=$(echo "$orphans" | wc -l)
echo -ne "\033[1m==> $lines orphan package(s) found:\033[0m "
echo "$orphans" | while read line; do
IFS=' ' read -r -a array <<< "$line"
echo -ne "${array[0]}\033[38;5;243m-${array[1]}\033[0m "
done
echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment