Export your Homebrew setup β taps, packages, casks, and Mac App Store apps β into a portable Brewfile and self-contained install script.
brew_export.sh snapshots your entire Homebrew environment and selected dotfiles into a single tarball you can drop on a new Mac and run. One script in, one script out.
- π¦ Dumps a
Brewfileviabrew bundleβ formulae, casks, taps, and MAS apps - π§ Detects custom taps and bakes them into the install script
- ποΈ Detects Mac App Store apps (via
mas) and handles sign-in gracefully on restore - ποΈ Scans
~and~/.sshfor dotfiles and lets you select which ones to include - β¨ Interactive multi-select via
fzf(falls back to a numbered checklist iffzfisn't installed) - ποΈ Packages everything into a single
<name>.tar.gztarball β Brewfile, install script, and dotfiles together - π Security warnings when SSH keys or sensitive files are included
- π¨ Colorized, emoji-annotated output throughout
- macOS
- Homebrew
brew bundle(included with Homebrew)
Optional but recommended:
masβ required to capture Mac App Store apps; installed automatically if App Store apps are detected (brew install mas)fzfβ enables interactive dotfile selection (brew install fzf)
# Clone the repo
git clone https://github.com/zackwag/brew-export.git
cd brew-export
# Make executable
chmod +x brew_export.sh
# Run β defaults to your hostname as the output name
./brew_export.sh
# Or specify a custom name
./brew_export.sh my-macbook-setupThis produces a tarball in the current directory:
my-macbook-setup.tar.gzmy-macbook-setup/
βββ my-macbook-setup.Brewfile # brew bundle dump output
βββ my-macbook-setup_install.sh # self-contained restore script
βββ dotfiles/ # any dotfiles you selected
βββ .zshrc
βββ .gitconfig
βββ .ssh/
βββ config
Transfer the tarball to the new Mac, then:
tar -xzf my-macbook-setup.tar.gz
cd my-macbook-setup
bash my-macbook-setup_install.shThe install script will walk through these steps automatically:
| Step | What happens |
|---|---|
| 1. Homebrew | Checks if Homebrew is installed; installs it if not (handles Apple Silicon path automatically) |
| 2. Custom taps | Re-adds any custom taps captured at export time |
| 3. App Store | Checks mas sign-in; if not signed in, installs everything else and exits cleanly with instructions |
| 4. Brew bundle | Runs brew bundle install from the Brewfile |
| 5. Dotfiles | Copies dotfiles to ~; prompts per file if one already exists |
When a dotfile already exists at the destination, you'll be prompted:
β οΈ Already exists: ~/.zshrc
What would you like to do?
[o] Overwrite [s] Skip [b] Backup and overwrite
>Choosing backup saves the existing file as .zshrc.bak.YYYYMMDDHHMMSS before overwriting.
If your Brewfile contains App Store apps, brew_export.sh will automatically install mas via Homebrew if it isn't already present β no manual setup required.
If the target machine isn't signed into the App Store when the install script runs, it will install all non-MAS packages first, then exit with clear instructions to sign in and re-run.
β οΈ If you include~/.sshfiles, your tarball may contain private keys.
- The script will warn you prominently when SSH files are selected
- Store and transfer the tarball securely β encrypted drive, private channel, etc.
- Never commit a tarball containing SSH keys or secrets to a public repository
MIT