To skip the waffle, go straight to the dotfiles.
Previously, I had tried to use Ansible to maintain my dotfiles over both OSX and Linux machines. It was however very tedious keeping everything in sync.
Then I found out how to use a bare git repo to maintain dotfiles. I find this
approach ingenious, as there is no symlinking or any other shenanigans. Just
edit the dotfiles as normal, and git will track the changes. The fact that
it’s a bare repo means you can put it anywhere, which means you can version the
whole of $HOME
, but you don’t get messy nested git repos.
The (small) downside is you have to specify the location of the bare repo for
each operation. The solution is an alias for your favourite shell. I chose to
make a new alias/command called dot
.
I’m currently not using any Linux machines, but I do look forward to playing with different branches for different OSes.
The heavy lifting is done by Homebrew and a Brewfile. To be honest, Homebrew is what makes Apple machines competitive developer machines for me. (The hardware also doesn’t hurt. I’m looking at you Lenovo, and you Linux graphics drivers.)
I try to follow the freedesktop.org XDG Base Directory Specification as closely as possible even on macOS, just to make those Linux transitions easier. I also thing the XDG directory structure is really good for backing up and I hate dotfile clutter in my home directory.
There is some other cleverness, e.g. the way I back up sensitive files that you don’t want in a repository. There’s a backup and bootstrap script. The backup script creates a tarball that contains all SSH keys and things like that. The tarball is then used to bootstrap the restore. As it contains all SSH keys, the chicken and the egg problem is solved and I can pull things from Github or other sources.
I copy the tarball with a USB stick. Hardly high-tech, but it works.
Sadly, due to the Mac App Store settings some software up automatically isn’t possible. I have no way of backing up the licenses, but I’m considering re-buying some of the software outside the App Store to make this less annoying.
Finally, I have a 2FA hardware key that I’m setting up. I’ll need to figure out which parts of the setup procedure change when using it.
I hope you find the dotfiles useful. They’re MIT licensed, so you should be able to use them anywhere including work.
(I have modified Mathias Bynens’ legendary macOS defaults script to suit my needs, which is also MIT licensed.)
Enjoy!