Skip to content

Instantly share code, notes, and snippets.

@jaredhowland
Last active October 16, 2023 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredhowland/45d449eff737e65141ebf1b03ece85ce to your computer and use it in GitHub Desktop.
Save jaredhowland/45d449eff737e65141ebf1b03ece85ce to your computer and use it in GitHub Desktop.
Homebrew
#!/usr/bin/env zsh
# Setup script for a new macOS machine
# Version of Ruby to use with `chruby`
rubyver="3.2.2"
# Bold font
bold=$(tput bold)
normal=$(tput sgr0)
# Emojis
comp="💻 "
exclam="❗ "
question="❓ "
tool="🛠️ "
check="✅ "
info="ℹ️ "
celebrate="🎉 "
# Horizontal rule to separate commands
hr() {
echo; echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"; echo
}
# Begin setup
echo "${comp}${bold}Starting macOS setup${normal}"
echo "${exclam}Sudo, make me a sandwich"
sudo -v
hr
echo "${tool}Installing Oh My Zsh…"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
echo "${check}Oh My Zsh installed"
hr
echo "${tool}Installing Homebrew…"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "${check}Homebrew installed"
hr
echo "${tool}Adding Homebrew to PATH…"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
source ~/.zshrc
echo "${check}Homebrew added to PATH"
hr
echo "${tool}Turning off Homebrew analytics…"
brew analytics off
echo "${check}Homebrew analytics turned off"
hr
echo "${question}Checking that Homebrew is ready for use…"
brew doctor
echo "Troubeshoot any errors identified above manually"
hr
echo "${tool}Creating LaunchAgents directory for Homebrew autoupdates…"
sudo mkdir -p ~/Library/LaunchAgents
echo "${check}LaunchAgents directory created"
hr
echo "${tool}Setting up autoupdates every 24 hours for Homebrew…"
brew autoupdate start --upgrade --cleanup
echo "${check}Homebrew autoupdates enabled"
hr
echo "${tool}Updating Homebrew recipes…"
brew update
echo "${check}Homebrew recipes updated"
hr
echo "${tool}Installing Homebrew packages…"
# `chruby` is for managing Ruby versions (mostly for Jekyll) <https://github.com/postmodern/chruby>
# `tectonic` is for LaTeX <https://tectonic-typesetting.github.io/en-US/>
PACKAGES=(
1password
adguard
affinity-designer
affinity-photo
affinity-publisher
alfred
appcleaner
bartender
bbedit
cardhop
chruby
fantastical
firefox
github
gpg-suite-no-mail
imageoptim
iterm2
mamp
phpstorm
ruby-build
sequel-ace
tectonic
transmit
mas
)
brew install ${PACKAGES[@]}
echo "${check}Homebrew packages installed"
hr
echo "${tool}Adding chruby to ~/.zshrc…"
(echo; echo '# `chruby` for Ruby versions in Jekyll') >> ~/.zshrc
(echo 'source $HOMEBREW_PREFIX/opt/chruby/share/chruby/chruby.sh') >> ~/.zshrc
(echo 'source $HOMEBREW_PREFIX/opt/chruby/share/chruby/auto.sh') >> ~/.zshrc
source ~/.zshrc
echo "${check}chruby added to ~/.zshrc"
hr
echo "${tool}Adding ruby-build to ~/.zshrc…"
(echo; echo '# `ruby-build` for Ruby versions in Jekyll') >> ~/.zshrc
(echo 'export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"') >> ~/.zshrc
source ~/.zshrc
echo "${check}ruby-build added to ~/.zshrc"
hr
echo "${tool}Adding latest version of Ruby…"
ruby-build ${rubyver} ~/.rubies/ruby-${rubyver}
source ~/.zshrc
chruby ruby-${rubyver}
echo "${check}Ruby updated to latest version"
hr
echo "${tool}Installing alternate versions of packages…"
brew tap homebrew/cask-versions
brew install dash6
echo "${check}Alternate Homebrew package versions installed"
hr
echo "${tool}Installing Mac App Store apps…"
echo "1Password for Safari…"
mas install 1569813296
echo "Amphetamine…"
mas install 937984704
echo "Drafts…"
mas install 1435957248
echo "Keynote…"
mas install 409183694
echo "Numbers…"
mas install 409203825
echo "MacFamilyTree 10…"
mas install 1567970985
echo "Pages…"
mas install 409201541
echo "PixelMator Pro…"
mas install 1289583905
echo "Things…"
mas install 904280696
mas upgrade
echo "${check}Mac App Store apps installed"
hr
echo "${tool}Cleaning up…"
brew cleanup
echo "${check}Homebrew cleaned up"
hr
echo "${info}${bold}Apps not installed using this script that you may want to install later:${normal}"; echo
echo "${bold}Homebrew apps:${normal}"
echo "• brew install dbngin"
echo "• brew install herd"
echo "• brew install postbox"
echo "• brew install --cask safari-technology-preview"; echo
echo "${bold}Mac App Store apps:${normal}"
echo "• Patterns: mas install 429449079"
echo "• Photos Exif Editor: mas install 1202851767"
echo "• Scenecuts: mas install 1540491573"
echo "• UISP Mobile: mas isnstall id1183022489"
echo "• UniFi: mas install id1057750338"; echo
echo "${bold}Manual installation apps:${normal}"
echo "• Nova <https://nova.app/>"
echo "• Wireshark <http://wireshark.org>"
hr
cd ~/Desktop
brew bundle dump
echo "${celebrate}${bold}macOS setup completed!${normal}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment