What This Script Does
The brew-setup.sh script is the flagship entry point for the entire Brew Scripts toolkit. It provides a complete, end-to-end Homebrew installation and configuration experience that is designed to be both thorough and approachable, even for users who have never opened Terminal before. Rather than making assumptions about what you need, it walks you through every step interactively and lets you decide what to install, what to skip, and how to configure your system.
When you launch the script, the first thing it does is detect your Mac's processor architecture. This matters because Apple silicon (M-series) Macs use a different Homebrew installation path than older Intel-based Macs. On Apple Silicon, Homebrew installs to /opt/homebrew, while Intel Macs use /usr/local. The script handles this distinction automatically, ensuring that all subsequent PATH configurations and package installations point to the correct location for your hardware.
Next, the script checks whether Homebrew is already installed. If it is, the script validates the installation and moves on. If Homebrew is not present, the script downloads and runs the official Homebrew installer. It also checks for and installs the Xcode Command Line Tools if they are not already available, since many Homebrew packages depend on these tools for compilation.
Once Homebrew is ready, the script configures your shell environment. It adds the brew shellenv line to ~/.zprofile, ~/.zshrc, ~/.bash_profile and ~/.bashrc (only where it is missing), so brew works in zsh and bash alike. It also adds export HOMEBREW_NO_AUTO_UPDATE=1 and export HOMEBREW_NO_ENV_HINTS=1 to ~/.zshrc and ~/.bash_profile, which stop Homebrew updating itself before every install and hide its environment hints. Then it runs brew analytics off to turn off Homebrew's anonymous usage analytics, and brew doctor to check the installation.
Next comes app installation. The script reads the CUSTOM_APPS list from your config file, shows the configured apps grouped by category (development, productivity, creative, communication, utilities) with each category's enabled or disabled status, and asks once whether to install them. Apps already in /Applications are skipped. The list ships entirely commented out, so a fresh config installs no apps until you add your own.
Throughout the entire process, the script writes detailed logs to a file at ~/Library/Logs/HomebrewSetup.log. Every action, every success, and every error is recorded with timestamps and severity levels. If something goes wrong, the log file is your first resource for diagnosing the issue. The script also supports a --debug flag that produces even more verbose output for advanced troubleshooting scenarios.
Perhaps the most important safety feature is --dry-run mode. When you pass this flag, the script simulates the entire setup process without actually making any changes to your system. It shows you exactly what would happen — which packages would be installed, which files would be modified, and which system checks would pass or fail — without touching anything. This is strongly recommended for your first run so you can verify that everything looks correct before committing.