Skip to content

Commit

Permalink
🍻 Update homebrew scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stoe committed Apr 10, 2024
1 parent 47215d8 commit 6879df3
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion scripts/brew/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,47 @@ set -eo pipefail
print -P "\n[ %5Fhomebrew%f ] 🍺 cleanup\n"

# check if the Brewfile.all file exists
[ ! -f Brewfile.all ] && print -P "✘ %178Faborting%f Brewfile.all not found" && exit 1
[ -f Brewfile.all ] && print -P "βœ“ %178Ffound%f Brewfile.all, deleting...\n" && rm Brewfile.all > /dev/null 2>&1 && rm Brewfile.all.lock.json > /dev/null 2>&1

# check if the Brewfile file exists
[ ! -f Brewfile ] && print -P "✘ %178Faborting%f Brewfile not found" && exit 1
# check if the Brewfile.optional file exists
[ ! -f Brewfile.optional ] && print -P "✘ %178Faborting%f Brewfile.optional not found" && exit 1

# get the local computer's name and save it to a variable
machine_name=$(hostname)

# get the contents of the Brewfile and Brewfile.optional files and join them
brewfile_all="$(cat Brewfile)$(cat Brewfile.optional)"

# switch statement to check the machine_name variable
case $machine_name in
"0x73746f65")
print -P "[ %5Fhomebrew%f ] 🍺 πŸ’Ό\n"

# check if the Brewfile.work file exists
[ ! -f Brewfile.work ] && print -P "✘ %178Faborting%f Brewfile.work not found" && exit 1

# get the contents of the Brewfile.work file and join it with the contents of the Brewfile_all variable
brewfile_all="$brewfile_all$(cat Brewfile.work)"
;;
"6x73746f65")
print -P "[ %5Fhomebrew%f ] 🍺 🏠\n"

# check if the Brewfile.personal file exists
[ ! -f Brewfile.personal ] && print -P "✘ %178Faborting%f Brewfile.personal not found" && exit 1

# get the contents of the Brewfile.personal file and join it with the contents of the Brewfile_all variable
brewfile_all="$brewfile_all$(cat Brewfile.personal)"
;;
*)
print -P "✘ %178Faborting%f Unknown machine name: $machine_name"
exit 1
;;
esac

# write the contents of the joined Brewfile files to a new file
echo "$brewfile_all" > Brewfile.all

# execute command
cmd="brew bundle cleanup --file Brewfile.all --force"
Expand Down

0 comments on commit 6879df3

Please sign in to comment.