Forked from dakcarto/find_homebrew-installed-w-options.sh
Created
September 2, 2018 08:59
-
-
Save newloong/f61d468301f4b70f4e8ef117c838b098 to your computer and use it in GitHub Desktop.
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 | |
# assign env var, if set | |
HB="${HOMEBREW_PREFIX:=/usr/local}" | |
find -L "${HB}/opt" -name 'INSTALL_RECEIPT.json' -maxdepth 2 -print > /tmp/homebrew-installed.txt | |
printf '' > /tmp/homebrew-installed-w-options.txt | |
NAME='' | |
OPTIONS='' | |
NAMES='' | |
NAME_OPTS='' | |
while IFS= read -r file | |
do | |
# get the formula name | |
NAME=$(printf "$file" | sed -E "s|^${HB}/opt/([^/]+)/INSTALL_RECEIPT.json$|\1|") | |
# get, cleanup and append used options | |
OPTIONS=$(grep -l -v "\"used_options\":\[\]" "$file") | |
if [ -z "$OPTIONS" ]; then | |
NAMES+="${NAME} | |
" | |
else | |
OPTIONS=$(sed -E -e 's/^.+"used_options":\[([^]]+)\].*$/\1/' -e 's/"//g' -e "s/,/ /g" "$file") | |
NAME_OPTS+="${NAME} ${OPTIONS} | |
" | |
fi | |
done < /tmp/homebrew-installed.txt | |
printf "${NAME_OPTS}" >> /tmp/homebrew-installed-w-options.txt | |
printf "${NAMES}" >> /tmp/homebrew-installed-w-options.txt | |
open /tmp/homebrew-installed-w-options.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment