Skip to content

Instantly share code, notes, and snippets.

@chew-z
Last active June 1, 2017 05:55
Show Gist options
  • Save chew-z/0a071933c3050509b29de6960c1e1512 to your computer and use it in GitHub Desktop.
Save chew-z/0a071933c3050509b29de6960c1e1512 to your computer and use it in GitHub Desktop.
Script to sieve brew packages and get list of standalone and dependants
#!/usr/bin/env zsh
OLDIFS=$IFS
IFS=$'\r\n'
GLOBIGNORE='*'
command eval 'BrewList=($(brew list))'
Dependent=()
Independent=()
for b in "${BrewList[@]}"; do
printf '.'
Deps=$(brew uses --installed $b | tr '\n' ' ')
if [[ -z "$Deps" ]]; then
Independent+=("$b")
else
Dependent+=("$b : $Deps")
fi
done
echo "\n-------------With Dependants---------------\n"
printf '%s\n' "${Dependent[@]}"
echo "\n-------------Standalone---------------\n"
printf '%s\n' "${Independent[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment