From 278063eb53187ed170bbcca9bb8ab078a9d242ba Mon Sep 17 00:00:00 2001 From: VectorKappa Date: Wed, 21 Aug 2024 13:29:02 +0200 Subject: [PATCH] Add paccompare() shell function --- .functions | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.functions b/.functions index 129dcc2..d835d90 100644 --- a/.functions +++ b/.functions @@ -321,3 +321,26 @@ weather(){ } +# For cleaning up aur helper cache +paccompare(){ +installed_packages=($(pacman -Q | cut -d' ' -f1)) + +current_dir_contents=(*) + +is_package() { + local dir="$1" + for package in "${installed_packages[@]}"; do + if [[ "$dir" == "$package" ]]; then + return 0 + fi + done + return 1 +} + +for dir in "${current_dir_contents[@]}"; do + if [[ -d "$dir" ]] && ! is_package "$dir"; then + echo "$dir" + fi +done +} +