Last active
December 12, 2023 20:13
-
-
Save tyjak/8bfc3cd340d443b6847ccd443b4a1acc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# GistID: 8bfc3cd340d443b6847ccd443b4a1acc | |
yaycachedir=~/.cache/yay | |
yaycache="$(find $yaycachedir -maxdepth 1 -type d | awk '{ print "-c " $1 }' | tail -n +2)" | |
echo "==> Keep last 2 installed versions" | |
/usr/bin/paccache -rvk2 $yaycache | |
for pkgdir in "$yaycachedir"/*/; do | |
pkgname=$(basename "$pkgdir") | |
## find package with binary download and keep last two one | |
#if [[ "$pkgname" =~ ^.*-bin$ ]]; then | |
cd "$pkgdir" | |
filetodel=($(find $pkgdir -maxdepth 1 -regex '.*.\(gz\|zip\|deb\|AppImage\|pacman\)' -exec ls -1t "{}" + | tail +3)) | |
for f in ${filetodel[@]}; do | |
if [ "$1" == "-prune" ]; then | |
echo "$f serait supprimé" | |
else | |
rm $f | |
echo "$f supprimé" | |
fi | |
done | |
#fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment