Created
August 11, 2025 22:36
-
-
Save ericrobskyhuntley/214b0febba932edcb196ef0a6c70d760 to your computer and use it in GitHub Desktop.
Automate macOS setup.
This file contains hidden or 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 | |
| set -euo pipefail | |
| BREW_FORMULAE=( | |
| gdal | |
| r | |
| node | |
| pandoc | |
| pandoc-crossref | |
| ) | |
| BREW_CASKS=( | |
| basictex | |
| iterm2 | |
| basictex | |
| cyberduck | |
| firefox | |
| github | |
| libreoffice | |
| signal | |
| spotify | |
| vlc | |
| zotero | |
| proton-mail | |
| proton-mail-bridge | |
| proton-drive | |
| proton-pass | |
| protonvpn | |
| pgadmin4 | |
| qgis@ltr | |
| rstudio | |
| vscodium | |
| ) | |
| install_xcode_tools() { | |
| if ! xcode-select -p &>/dev/null; then | |
| echo "Installing Xcode Command Line Tools..." | |
| xcode-select --install | |
| until xcode-select -p &>/dev/null; do | |
| sleep 5 | |
| done | |
| else | |
| echo "Xcode Command Line Tools already installed." | |
| fi | |
| } | |
| install_rosetta() { | |
| if /usr/bin/pgrep oahd >/dev/null 2>&1; then | |
| echo "Rosetta is already installed." | |
| else | |
| echo "Rosetta is not installed. Attempting to install..." | |
| # Attempt to install Rosetta | |
| /usr/sbin/softwareupdate --install-rosetta --agree-to-license | |
| if [[ $? -eq 0 ]]; then | |
| echo "Rosetta installation successful." | |
| else | |
| echo "Rosetta installation failed. You may need to run this script with sudo or install manually." | |
| fi | |
| fi | |
| } | |
| install_homebrew() { | |
| if ! command -v brew &>/dev/null; then | |
| echo "Installing Homebrew..." | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| else | |
| echo "Homebrew already installed." | |
| fi | |
| } | |
| install_brew_formulae() { | |
| echo "Installing Homebrew formulae..." | |
| for formula in "${BREW_FORMULAE[@]}"; do | |
| if ! brew list --formula "$formula" &>/dev/null; then | |
| brew install "$formula" | |
| else | |
| echo "$formula already installed." | |
| fi | |
| done | |
| } | |
| install_brew_casks() { | |
| echo "Installing Homebrew casks..." | |
| for cask in "${BREW_CASKS[@]}"; do | |
| if ! brew list --cask "$cask" &>/dev/null; then | |
| brew install --cask "$cask" | |
| else | |
| echo "$cask already installed." | |
| fi | |
| done | |
| } | |
| install_xcode_tools | |
| install_rosetta | |
| install_homebrew | |
| install_brew_formulae | |
| install_brew_casks | |
| echo "Setup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment