Last active
November 19, 2023 18:34
-
-
Save thibaultcha/10712262 to your computer and use it in GitHub Desktop.
Ever wondered which of your homebrew formulas are unused legacy dependencies? Run this!
This file contains 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/bash | |
GREEN="\033[1;32m"; | |
RESET="\033[m"; | |
echo "Searching for standalone formulae..."; | |
dependencies=(); | |
for formula in $(brew list); do | |
deps=(`brew uses $formula --installed | tr '\n' ' '`); | |
# Add the formula if it's being used by another, installed one | |
if [ ${#deps[@]} -lt 1 ]; then | |
dependencies+=($formula); | |
fi | |
done | |
if [ ${#dependencies[@]} -gt 1 ]; then | |
echo -e "${GREEN}${#dependencies[@]} standalone formulae found${RESET}"; | |
for formula in "${dependencies[@]}"; do | |
echo $formula; | |
done | |
echo "None of these formulae are used by any other formula, some of them might be legacy dependencies..."; | |
else | |
echo "No standalone formula found"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, just FYI there's a built-in command for this, which happens to be pretty quick since it analyzes the whole dependency tree at once: