-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrew_inventory
executable file
·60 lines (45 loc) · 1.16 KB
/
brew_inventory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
if [ $# -eq 1 ]; then
file=$1
else
file=brew_inventory.md
fi
which -s jq
if [ $? -ne 0 ]; then
echo "Installing jq..."
(brew install jq)
fi
cat << EOF >$file
# Brew Inventory
Inventory created at: $(date)
## Brews
EOF
echo "Getting brews..."
brew info --json=v1 $(brew list --formula -1) | jq -r '.[] | select(.installed[0].installed_as_dependency == false) | "- [x] " + .name + ": " + .desc?' >> $file
cat << EOF >>$file
## Casks
EOF
echo "Collecting casks..."
for c in $(brew list --cask -1); do
echo -n "- [x] $c: " >> $file
info=$(brew cask info --json=v1 $c 2>/dev/null)
if [ $? -ne 0 ]; then
echo "(failed to read homepage information)" >>$file
else
echo $info | jq -r '.[].homepage' 2>/dev/null >>$file
fi
done
cat << EOF >>$file
## Installed taps
EOF
echo "Enumerating taps..."
brew tap 2&>1 >/dev/null
for t in $(brew tap 2>/dev/null); do
case $t in
"homebrew/binary" | "homebrew/devel-only" | "homebrew/games" | "homebrew/science" | "homebrew/versions" | "homebrew/x11")
echo "Ignoring deprecated tap $t";;
*)
echo "- [x] $t" >> $file
esac
done
echo "Done!"