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.

Usage

Run the script from the root of the Brew Scripts project directory. It ships executable, so there is no chmod step. On a first run it also creates your config file if you have not made one, then tells you where it is.

# Preview all changes without modifying your system
./brew-setup.sh --dry-run

# Run the full interactive setup
./brew-setup.sh

# Run with verbose debug output for troubleshooting
./brew-setup.sh --debug

The script will prompt you at each major step, so you always have the opportunity to review what is about to happen and decide whether to proceed. If you need to stop the script at any point, press Ctrl+C to cancel safely.

Options and Flags

Flag Description
--dry-run, -d Simulate the entire setup process without making any changes. Shows what would be installed, configured, and modified. --check is an alias.
--non-interactive, -n Run without prompts, using the values in config/homebrew-scripts.conf.
--config-only, -c Only create or edit the configuration file, then exit without installing anything.
--debug Enable verbose output that prints detailed information about each step, including system calls and their results. Useful for diagnosing issues.
--version, -V Print the script version and exit.
--help, -h Show usage and exit.

Configuration

This script reads from your config/homebrew-scripts.conf file to determine which applications to install. The key settings that affect this script are:

Setting Effect
INSTALL_DEVELOPMENT_TOOLS When true (the default), CUSTOM_APPS entries in the development category install.
INSTALL_PRODUCTIVITY_APPS When true (the default), entries in the productivity category install.
INSTALL_CREATIVE_APPS When true, entries in the creative category install. Defaults to false.
INSTALL_COMMUNICATION_APPS When true (the default), entries in the communication category install.
INSTALL_UTILITIES When true (the default), entries in the utilities category install.
CUSTOM_APPS The apps to install, one per line as "cask-name:Display Name:category" (for example "firefox:Firefox:productivity"), inside the config file's EDIT HERE block. Every entry ships commented out, so nothing is enabled by default. The category switches above only filter this list; there are no built-in app lists.

If no configuration file is found, the script creates config/homebrew-scripts.conf from the example template and uses it. Run ./brew-setup.sh --config-only to create it without doing anything else, then edit its EDIT HERE block.

What Gets Changed

Understanding exactly what this script modifies on your system is important. Here is a complete list of changes the script may make:

  • Homebrew installation — Installed to /opt/homebrew on Apple Silicon Macs or /usr/local on Intel Macs. This includes the Homebrew core, tap repositories, and the package cache directory.
  • Shell profiles — The brew shellenv line is added, where missing, to ~/.zprofile, ~/.zshrc, ~/.bash_profile and ~/.bashrc. HOMEBREW_NO_AUTO_UPDATE=1 and HOMEBREW_NO_ENV_HINTS=1 are exported in ~/.zshrc and ~/.bash_profile.
  • Homebrew analytics — Turned off with brew analytics off.
  • Config file — config/homebrew-scripts.conf is created from the example template on first run if you have not made one.
  • Xcode Command Line Tools — If not already present, these are installed via Apple's software update mechanism. They provide essential compilers, libraries, and headers needed by many Homebrew packages.
  • Applications — Any apps you approve during the interactive selection are installed via brew install --cask and placed in your /Applications directory.
  • Log file — A detailed log is created at ~/Library/Logs/HomebrewSetup.log recording every action taken during the setup process.

No changes are made to system preferences or system-level configuration. Apart from the Command Line Tools and Homebrew's own directories, everything listed above lives in your user account.

Related Scripts

  • Quick Bootstrap — A faster, opinionated alternative that requires no configuration file and installs a curated set of development tools.
  • Essential Apps Installer — If Homebrew is already installed and you just need to batch-install apps, this focused script is a lighter option. It has its own list: edit the EDIT HERE block at the top of the script first.