Skip to content

Commit

Permalink
🍻 Create homebrew scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stoe committed Mar 23, 2024
1 parent 987e120 commit 7d327ac
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config/*
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,homebrew

### Homebrew ###
Brewfile.all
Brewfile*.lock.json

### Linux ###
Expand Down
2 changes: 2 additions & 0 deletions Brewfile β†’ scripts/brew/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ brew "goreleaser"
brew "node"
brew "nvm"

brew "rbenv"

#/ -----------------------------------------------------------------------------
#/ brew install --cask

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Brewfile.personal β†’ scripts/brew/Brewfile.personal
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
cask "parallels"
cask "sonos"
cask "steam", args: { require_sha: false }
cask "obs"
2 changes: 0 additions & 2 deletions Brewfile.work β†’ scripts/brew/Brewfile.work
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ brew "azure-cli"
# brew "ansible"
# brew "terraform"

brew "rbenv"

brew "python"
brew "pipenv"
# brew "virtualenv"
Expand Down
14 changes: 14 additions & 0 deletions scripts/brew/cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/zsh

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

# execute command
cmd="brew bundle cleanup --file Brewfile.all --force"
print -P "%244F> $cmd%f" && eval "$cmd"

print -P "\n[ %76Fβœ“%f ] 🍺 done"
51 changes: 51 additions & 0 deletions scripts/brew/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/zsh

set -eo pipefail

print -P "\n[ %5Fhomebrew%f ] 🍺 install\n"

# 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 --file Brewfile.all"
print -P "%244F> $cmd%f" && eval "$cmd"

print -P "\n[ %76Fβœ“%f ] 🍺 done"

0 comments on commit 7d327ac

Please sign in to comment.