Dotfiles for Developers — Part 2

In Part 1 of this series, we discussed setting up your machine with a basic toolset using Homebrew and Oh My Zsh. I highly recommend checking it out before beginning here (if you haven’t already).

Homebrew Cask

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
==> Formulae
spotify-tui spotifyd
==> Casks
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

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:

mas install 1482454543

Homebrew Bundle

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.

Example Brewfile

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
brew "composer"
brew "coreutils"
brew "git"
brew "mackup"
brew "mysql"
brew "node"
brew "php"
brew "pygments"
brew "wget"
brew "zsh-syntax-highlighting"
cask "caffeine"
cask "imageoptim"
cask "kaleidoscope"
cask "postman"
cask "responsively"
cask "slack"
cask "spotify"
cask "sourcetree"
mas "Xcode", id: 497799835

Note: You may notice the mas line in our example Brewfile above. This is because the mas-cli tool for installing Mac App Store software is integrated with Homebrew Bundle!


Mackup Logo
Mackup Logo

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.


cp ~/.gitconfig ~/Dropbox/Mackup/.gitconfig
rm ~/.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


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:

touch ~/.mackup.cfg

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.

# ~/.mackup.cfg[storage]
engine = file_system
path = .dotfiles
directory = mackup

Note: You can get a full list of applications that Mackup supports by running mackup list.

Sample terminal output showing a dry-run of Mackup.
Sample terminal output showing a dry-run of Mackup.
Sample terminal output showing a dry-run of Mackup.

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 --dry-run:

mackup backup

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 mackup restore.

Custom Mackup Configurations

To get started, create a .mackup folder in your home directory:

mkdir ~/.mackup

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:

touch ~/.mackup/acmeapp.cfg

In that file, you would add something similar to the following:

# ~/.mackup/acmeapp.cfg[application]
name = AcmeApp
Library/Application Support/AcmeApp

Mackup will now backup your custom application configuration when running mackup backup and will show your AcmeApp configuration when running mackup list.

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 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:

# ~/.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.


Web developer with a passion for #html, #css, #js and a preference for #php and #laravel. I also have a small obsession with #devops and shell scripting.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store