diff options
-rwxr-xr-x | haur | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -133,6 +133,7 @@ else fi if [[ $CLEAR_CACHE == true ]]; then + REMOVED=false if test -f "$HOME/.haur_cache"; then echo "${blue}Clearing cache...${normal}" while IFS= read -r line || [[ -n "$line" ]]; do @@ -140,7 +141,19 @@ if [[ $CLEAR_CACHE == true ]]; then rm -rf "$HOME/.haur/$line" done < "$HOME/.haur_cache" rm ~/.haur_cache - else + REMOVED=true + fi + + dirs=() + while IFS= read -r -d '' dir; do + dirs+=($(basename "${dir#*/}")) + done < <(find ~/.haur -maxdepth 1 -mindepth 1 -type d -print0) + + for DIRECTORY in "${dirs[@]}"; do + pacman -Q $DIRECTORY &>/dev/null || echo "${blue}Removing $DIRECTORY${normal}" && rm -rf "$HOME/.haur/$DIRECTORY" && REMOVED=true + done + + if [[ $REMOVED == false ]]; then echo "${blue}Nothing to clear${normal}" fi fi
\ No newline at end of file |