GenerateBrewFile.sh is a single-file Bash utility that builds a comprehensive Brewfile for your macOS machine. It combines the output of brew bundle dump with metadata about your Mac App Store purchases and locally installed .app bundles so that you have a complete, human-readable inventory of the software on your Mac.
- Dumps all installed Homebrew formulae, casks, and taps using
brew bundle dump. - Optionally includes inline descriptions for formulae/casks when
brew bundle dump --describeis supported. - Adds a Mac App Store section (via the
masCLI) showing app names and IDs. - Scans
/Applicationsand~/Applicationsfor manually installed.appbundles and suggests matching casks where available. - Notes any remaining apps that do not have an obvious cask, helping you track manual install steps.
- Works with the stock macOS Bash 3.2 runtime (no
mapfile, uses POSIX-friendly constructs).
| Requirement | Purpose |
|---|---|
| macOS | The script depends on Homebrew and the macOS application bundle layout. |
| Homebrew | Provides the brew command used to dump your environment. If brew is missing the script attempts a non-interactive installation and configures the current shell session to use it. |
mas CLI (optional) |
Enables the Mac App Store section; without it the script records that MAS apps were skipped. When mas is missing the script installs it with Homebrew before proceeding. |
GenerateBrewFile.sh is published in the main Homebrew tap starting with
version 0.1.1. Install or upgrade it like any other core formula (release
notes live on the v0.1.1 GitHub tag):
brew install generate-brewfile
# or
brew upgrade generate-brewfileThe formula bundles the GenerateBrewFile.sh script as the generate-brewfile
CLI. It includes an automated brew test that exercises the --help and
--version flags to keep parity with the upstream release process.
If you would like to track the latest commits between tagged releases you can
use Homebrew's --HEAD flag:
brew install --HEAD generate-brewfileHomebrew will clone the Git repository directly and build the CLI from the
current main branch.
Note: Homebrew/homebrew-core accepts projects maintained by individuals. The formula points to the canonical repository under the
timbroderaccount—no GitHub organization is required as long as the tagged release and checksum remain stable.
Clone the repository (or copy the script) and make it executable:
git clone https://github.com/timbroder/GenerateBrewFile.sh.git
cd GenerateBrewFile.sh
chmod +x GenerateBrewFile.shYou can now run the script directly or move it somewhere on your $PATH (for example ~/bin).
From the repository root (or wherever the script lives), run:
./GenerateBrewFile.shBy default this writes ~/Brewfile, includes descriptions when supported, and prints progress messages. You can override the
output location directly from the command line:
./GenerateBrewFile.sh --brewfile /path/to/custom.BrewfileTo confirm which release is installed, run:
./GenerateBrewFile.sh --versionThe script will then:
- Ensure that both
brewand themasCLI are available, installing them automatically when necessary. - Require that
brewexists, then runbrew bundle dump --force --file "$BREWFILE" --describe. - If the
masCLI is installed and logged in, append your Mac App Store apps (mas "Display Name", id: 123456789). - Scan
/Applicationsand~/Applicationsfor.appbundles that do not already appear in your MAS list, skip obvious Apple system apps, and try to match each bundle to a Homebrew cask token. - Record suggested cask names (e.g.,
# cask "google-chrome" # Google Chrome -> google-chrome). - List any remaining
.appbundles that could not be mapped to a cask so you can document manual installation steps. - Finish with a reminder to validate using
brew bundle check.
| Variable | Default | Description |
|---|---|---|
BREWFILE |
$HOME/Brewfile |
Path to write the generated Brewfile. Overridden by --brewfile when provided. |
DESCRIBE |
1 |
When set to 1 (default) the script adds --describe so formulae/casks include the Homebrew description text. Set to 0 to omit descriptions. |
QUIET |
0 |
Set to 1 to suppress log output (only errors will print). |
You can combine these for different scenarios:
# Generate into the current directory without descriptions
BREWFILE="$(pwd)/Brewfile" DESCRIBE=0 ./GenerateBrewFile.sh
# Run silently and output to a custom path
QUIET=1 ./GenerateBrewFile.sh --brewfile "$HOME/Documents/work-mac.Brewfile"GenerateBrewFile.sh inventories multiple categories of software:
- Homebrew formulae – Core packages installed via
brew install. - Homebrew casks – GUI apps, fonts, and other binary artifacts installed via
brew install --cask. - Homebrew taps – Additional tap repositories required by the above packages.
- Mac App Store apps – Applications associated with your Apple ID, collected with the
masCLI. - Manually installed
.appbundles – Applications living in/Applicationsor~/Applicationsthat are not otherwise tracked; the script suggests casks or flags them for manual follow-up.
# ------------------------------
# Mac App Store apps (via mas)
# ------------------------------
mas "Xcode", id: 497799835
mas "Things 3", id: 904280696
# ------------------------------
# Suggestions for manually installed apps
# ------------------------------
# Likely available as casks (unmanaged right now). Consider adding lines like:
# cask "google-chrome" # Google Chrome -> google-chrome
# cask "spotify" # Spotify -> spotify
#
# Remaining apps that don't have an obvious cask:
# OmniGraffle
After generating your Brewfile you can confirm that Homebrew can satisfy it:
brew bundle check --file="/path/to/Brewfile"Resolve any missing dependencies, then commit the Brewfile to source control or store it alongside your personal backups.
Error: 'brew' is not installed or not on PATH.– Install Homebrew from brew.sh and ensurebrewis available in your shell.massection is missing. – Installmas(brew install mas) and log in (mas account) before running the script.- Applications missing from suggestions. – Some bundles have unconventional names. Re-run the script periodically to refresh suggestions, or manually add the relevant
caskor notes to your Brewfile.
Issues and pull requests are welcome! Please open an issue describing the improvement you have in mind, or submit a PR directly.
This project is licensed under the terms of the MIT License.
Vibe coded using ChatGPT.