How To Automate Homebrew Installs on Your New Mac or Linux
You don’t need to install Homebrew packages one by one
[Update: 2021–06–30]
If you are programming on macOS, chances are you use Homebrew. Even if you are a Linux user, you may be using Homebrew. I install most of my apps and tools with Homebrew. On my 2017 macOS, I installed about 100 formulae and 30 casks with Homebrew.
This month, I got a new MacBook Pro (M1 chip) and I didn’t want to install all the apps and tools one by one. So I created Automate Brew Installer (Abi). Abi creates GitHub Gists from your Homebrew formulae and casks. It also installs Homebrew formulae (packages) and casks from these gist lists.
Table of Contents
· Prerequisite
· Homebrew’s Formula, Cask, and Tap
· Installing Abi
· Log Into GitHub
· Creating Gists
∘ File name and description
∘ A secret gist
· Edit Gist Lists
· Automate Brew InstallationConclusion
Prerequisite
You need to have a GitHub account and some experience with a terminal.
Homebrew’s Formula, Cask, and Tap
Homebrew calls its package definition files “formulae.” Homebrew-Cask is an extension to install GUI applications. When you install Homebrew casks, you find them in your Applications directory. A Homebrew tap is a package created by a third party, like you and me.
Let’s get started using Abi.
Installing Abi
You can run the following on your terminal to install Abi:
brew tap shinokada/abi && brew install abi
Or using Awesome package manager:
awesome -i shinokada/abi
Log Into Github
When you install Abi, it will install Github CLI gh
. After installing Abi, log into GitHub using gh
on your terminal:
gh auth login
Follow the instructions to log into Github.
Creating Gists
Let’s create a Homebrew formula gist and a cask gist on your Mac:
abi leaves
This creates a Homebrew formula gist with the default file name and description. The default file name and descriptions are “my-brew-formula” and “My brew list.” It will open a browser to show your gist.
Let’s create a Homebrew cask gist with the default file name and description:
abi cask
The default file name and descriptions for a cask gist are “my-brew-cask-formula” and “My brew cask list.”
File name and description
You can create a Homebrew gist with your description and file name using -d "description" -f file-name
. Make sure that you have “cask” in the file name or description. Use quotes for your description since you will have spaces.
abi leaves -d "My brew list 2021-06-30" -f brew-list-mac-2017
abi cask -d "My brew cask list 2021-06-30" -f brew-cask-list-mac-2017
A public gist
You can create a public formula gist by using the -p
flag:
abi leaves -p
# Or adding description and file name
abi leaves -p -d "My secret gist" -f brew-list-2017
Edit Gist Lists
You may wish to edit the generated gist lists. Go through the gist and remove or add new formulae.
If you want to add more Homebrew formulae, find them on this website. Be careful not to mix formulae and casks. Casks have --cask
in their formulae.
Automate Brew Installation
Now on another Mac, let’s install formulae from your gist.
Install Abi:
brew tap shinokada/abi && brew install abi
Install Homebrew formulae from a gist. Using the install
flag installs the formulae from the Gist URL:
abi install Your-Gist-URL
For example:
abi install https://gist.github.com/shinokada/136f21f96170fb8f0fb0691bfd45242b
This will install Homebrew formulae and taps (remember that taps are listed with formulae).
Let’s install the Homebrew casks from a gist. Using the installcask
flag indicates installing cask formulae. Again, add your cask Gist URL:
abi installcask Your-Gist-URL
For example:
abi installcask https://gist.github.com/shinokada/32f0cc30fb48be090bf541ad387def47
When you need help:
abi -h
Find out if you have the latest Abi version:
abi -v
Conclusion
If you want to install GNU core utilities, the macGNU package will install them using Homebrew.
Or you can use Abi to install them. Both options will result in the same installation.
Are you looking for popular Homebrew packages? Please see Top Homebrew Packages for 2020 by
, Homebrew tools by , and 5 Must-Have Homebrew Packages for Command-Line Lovers by .Let me know what you think about Abi.
Happy coding!
If you liked my article and would like to receive my newsletter, please sign up.