Homebrew is great for installing essential command line tools and terminal software — but it can also be used to install most Mac apps as well! Using Homebrew to install your most used Mac apps can be a great way to quickly reinstall (and keep up to date) the apps running on your system.
Let’s say you wanted to install the Spotify app on your system using Homebrew. You can search for software by using the
brew search command:
$ brew search spotify
mutespotifyads spotify spotify-now-playing
In this example, you will see that our search returned 2 Formulae for Spotify related CLI tools and 3 Casks for apps that can be installed. Since we are trying to install the Spotify app, we just need to
brew install it:
brew install spotify
That’s it! Now the Spotify app is installed and ready to use.
This will come in handy when we combine this with Homebrew Bundle (below) to automate the installation of all of our installed software.
Mac App Store
If you have software located in the Mac App Store that you would like to automate or install via the command line — then you will need to install a tool called mas-cli:
brew install mas
Each application in the Mac App Store has a product identifier which is also used for mas-cli commands. Using
mas list will show all of your currently installed applications and their product identifiers:
$ mas list
441258766 Magnet (2.5.0)
969418666 ColorSnapper2 (1.5.1)
465965038 Markdown Pro (1.0.9)
429449079 Patterns (1.2)
You can search for software using
mas search in order to return the matching identifier for the software you want to install:
$ mas search twitter
1482454543 Twitter (8.62)
… and then install using
mas install 1482454543
Homebrew comes with a really useful tool for setting up new machines called Homebrew Bundle. If you are familiar with Composer’s
composer.json or NPM’s
package.json, then you will feel right at home with how Bundle functions. Homebrew Bundle uses a
Brewfile that defines everything required to reinstall your whole Homebrew setup — including any installed software,
taps, and even fonts!
If you have been using Homebrew for awhile, you may already have many things installed and configured to your liking. You can generate a
Brewfile of everything you have previously installed by running:
brew bundle dump
You can then use the generated
Brewfile to reinstall everything on your system as it was previously by running the following:
brew bundle install
This command will run through your
Brewfile and install everything needed to get your system up and running.
Here is a small example of what a common
Brewfile will look like. Additionally, this is a good starting point if you are new to installing software with Homebrew — feel free to remove anything that you don’t need:
tap "homebrew/services"brew "composer"
brew "zsh-syntax-highlighting"cask "caffeine"
cask "sourcetree"mas "Xcode", id: 497799835
Note: You may notice the
masline in our example
Brewfileabove. This is because the mas-cli tool for installing Mac App Store software is integrated with Homebrew Bundle!
Mackup is an invaluable tool when it comes to:
- Backing up your application settings to a safe directory.
- Syncing your application settings among all of your workstations.
- Restoring your configuration on any fresh install.
It works very simply — Mackup will backup only configuration files (no cache or temporary files) to a location of your choice and then symlink them from their original location to the backup. The default backup location is Dropbox — but you can also use Google Drive, iCloud, or any sync directory that you would like.
Let’s say you would like to backup your Git configuration (
.gitconfig) to Dropbox. Running
mackup backup would do these things for you:
cp ~/.gitconfig ~/Dropbox/Mackup/.gitconfig
ln -s ~/Dropbox/Mackup/.gitconfig ~/.gitconfig
… and you can quickly restore this configuration by running
mackup restore, which would do the following:
ln -s ~/Dropbox/Mackup/.gitconfig ~/.gitconfig
You can install Mackup easily with Homebrew:
brew install mackup
Before getting started, you may want to configure the Mackup backup location. To do this, create a file called
.mackup.cfg in your home directory:
In that file — we can define our storage
engine, our storage
directory name, our storage
path, and a few other configuration options. You should check out the documentation for more information.
In this example, we are going to backup our configuration to a
~/.dotfiles path and into a directory called
mackup. Additionally, we also want to ignore the configration files for Adium and Subversion.
engine = file_system
path = .dotfiles
directory = mackup[applications_to_ignore]
Note: You can get a full list of applications that Mackup supports by running
Before we backup our system, run the following to test what Mackup will be backing up without actually executing anything:
mackup backup --dry-run
This command will show you a list of everything that will be backed up. If you see anything that you would prefer to ignore, add it to the
[applications_to_ignore] section of your config file.
When you are ready, execute the same command without
That’s it! Your configuration will now be backed up to the location you specified and can be restored at any time on any machine by running
Custom Mackup Configurations
Mackup may not support every application that you would like to have backed up out of the box. That’s okay — it also provides an easy way to specify your own configuration files for backup.
To get started, create a
.mackup folder in your home directory:
Let’s say you would like to add backup support for AcmeApp to Mackup. Simply create a configuration file for the application in your
~/.mackup directory and add the files that should be backed up and synced:
In that file, you would add something similar to the following:
name = AcmeApp[configuration_files]
Mackup will now backup your custom application configuration when running
mackup backup and will show your AcmeApp configuration when running
Tip: Take a look at the configuration files of other applications supported by Mackup to get a better idea of what files they backup and how they are configured.
Oh My Zsh and Mackup
As of this writing, Mackup had to remove Oh My Zsh support in order to resolve a bug when updating. We could write our own Mackup configuration file to backup our Oh My Zsh config — but there is an easier way!
As I mentioned in Part 1 of this series, your Oh My Zsh custom scripts can be changed to any directory you’d like by setting the
$ZSH_CUSTOM variable in your
.zshrc file. We can use this variable to set our Mackup backup location as the directory Oh My Zsh should look for custom scripts.
Assuming we are storing our Mackup backups in
~/.dotfiles/mackup, let’s start by copying your custom Oh My Zsh scripts there:
$ mkdir -p ~/.dotfiles/mackup/.oh-my-zsh
$ cp -R ~/.oh-my-zsh/custom ~/.dotfiles/mackup/.oh-my-zsh
We can now configure Oh My Zsh to look in this directory for our custom scripts by modifying our
# ~/.zshrc# Would you like to use another custom folder than $ZSH/custom?
…and now our custom Oh My Zsh scripts are safely backed up to our Mackup sync directory and Oh My Zsh is configured to look there for them.
We have now covered almost everything you need to know to setup and use Homebrew and Mackup on your machine to backup your system and restore it easily. In the final part of this series, we will try to tie all of this knowledge together by backing up your configuration to your own dotfiles Git repository. The goal (again) being to be able to deploy your backup on any new machine and to get yourself up and running with your preferred development environment as quickly as possible.