Skip to content

Instantly share code, notes, and snippets.

View albertored11's full-sized avatar
🐙

Alberto Redondo albertored11

🐙
View GitHub Profile
@albertored11
albertored11 / yaycache
Last active August 25, 2023 16:49
Script and hook to clean pacman and yay cache
#!/usr/bin/env bash
# Assuming yay is run by user with UID 1000
admin="$(id -nu 1000)"
cachedir="/home/$admin/.cache/yay"
removed="$(comm -23 <(basename -a $(find $cachedir -mindepth 1 -maxdepth 1 -type d) | sort) <(pacman -Qqm) | xargs -r printf "$cachedir/%s\n")"
# Remove yay cache for foreign packages that are not installed anymore
rm -rf $removed