QR Code contains TinyURL of this article.Setting Up a New Mac, the Painless Way

Apple “Rainbow” Logo
AppleCredit: . License: CC BY-SA 2.0

Introduction

If I remember correctly, OS X 10.4 (Tiger) was the first version of Apple’s Unix-based Operating System that I used.1  With every new release since then, I have upgraded my existing installation instead of choosing a fresh one and, with each new machine, I have restored a backup rather than start afresh.

The reason for this was simple. For years I have run a complex configuration: multiple web-servers,2 a selection of programming languages and compilers,3 local versions of websites running all kinds of CMS and back-end software, MongoDB and MySQL databases, along with a multitude of self-compiled programs and operating system hacks.

But time moves on and both my personal and professional computer requirements have changed considerably over the past decade. My work is now much more specialised than it once was, so my tool-set is smaller and less generalised than in the past. My operating system of choice, OS X, has evolved over the same time-frame, to the point where it is now much easier to deploy and maintain a working configuration and to create temporary sandboxes for experimentation and prototyping.

So when I got my new MacBook — some weeks ago now4 — I decided that I was going to go with a fresh installation. This would allow me to discard the cruft that had accumulated on its predecessors and thus run leaner and cleaner.

In the Old Days…

…setting up a new computer used to be a real pain: download all your applications, or dig out installation CD‍s; spend hours installing; search for cryptic license codes; configure application preferences. Then there’s email: configuring the accounts; importing email and the address book. The web-browser and bookmarks. The photo library, documents, iTunes music library… argh, the list goes on and on.

Today however, the process is different5 and, thankfully, a lot quicker and easier.

iCloud

OS X prompts for iCloud credentials on first powering up my new computer. Then, once the computer had booted up, I discovered that email, contacts, calendars, bookmarks, notes and reminders where all available without any further interaction on my part. To say this blew my mind is something of an understatement. I have read much criticism of iCloud. In the back of my mind it was a flaky, second-class citizen in the Apple ecosphere and I hadn’t given it much thought. But it had been reliably working away in the background — safeguarding my data — and I was grateful for it when setting up my new computer.

iTunes Match

I have a large iTunes library, upwards of 10,000 tracks. For a long time I have kept this library on an external hard drive as there simply isn’t enough room on my MacBook’s internal SSD. I have maintained a subscription to iTunes Match, since its launch, which allows me to still play my music, streamed from one of Apple’s giant server farms, when I’m away from home. I realised that I didn’t need to bother storing these files locally at all. I can always stream them.6 Besides, I tend to use Rdio more than iTunes these days, since Rdio has fantastic discovery tools and excels at handing off to different devices whilst maintaining track position. Now that Rdio is bankrupt, I use Apple’s iTunes and Music services almost exclusively.

App Store

Installing applications acquired through the Mac App Store is a no-brainer. The App Store associates applications with the iCloud account, so they’re available on all my Macs, both present and future. License keys are unnecessary, the App Store “knows” that I purchased the software after all! The coolest thing: one can simply click the “Install” button for the required applications then leave the App Store to do its thing, there is no need to babysit the process.

Command Line Tools

Strangely OS X, despite being a BSD-based Unix, is not supplied with basic Unix build tools like: make, GCC, clang, perl, svn, git, size, strip, strings, libtool, cpp, what and so on. However, Apple does make these available with the Command Line Tools package. It used to be that the developer would have to install the entire XCode suite to get these tools. Fortunately Apple now make it possible to install the Command Line Tools as a stand-alone package. To install them:

$ xcode-select --install

Homebrew

Homebrew bills itself as “the missing package manager for OS X” and it certainly delivers on that promise. I’ve been using Homebrew for years, it is an essential first install for all my Macs. We install Homebrew with the following command:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install the packages that I consider the absolute minimum:

$ brew install wget watch gnu-sed coreutils fortune aspell htop

Add basic imaging tools to the mix (imaging is one of my hobbies, I can’t work without these utilities):

$ brew install libjpeg libpng libexif exiv2

Homebrew Cask

As good as the Mac App Store is, there are essential applications that aren’t available, for one reason or another, from Apple’s repository.7  Salvation comes in the form of Homebrew Cask with its treasure trove of almost 2,000 applications. We install Homebrew Cask like so:

$ brew install caskroom/cask/brew-cask

Then we can install the software we require. At the time of writing, my list looks like this:

$ brew cask install appcleaner archey arq backblaze-downloader backuploupe bartender bittorrent-sync coconutbattery codekit commandq dropbox firefox flip4mac fluid gfxcardstatus github google-chrome iterm2 jumpcut little-snitch p4merge paparazzi perian pupil secrets sequel-pro sequential shortcat sophos-anti-virus-home-edition sublime-text superduper thisservice

Most application installations can run unattended with Homebrew Cask. However, there a handful that require manual tasks in order to complete the process (Little Snitch for example). We have to enter license keys for those apps that require them too. So Cask isn’t as seamless as the Mac App Store, but it still saves a heck of a lot of time.

Dropbox

At this point we’ve got Dropbox installed. This is significant because I store terminal configuration, shell script and my code editor’s support files here (so that I can easily synchronise my development environment between my MacBook and the iMac in my office).

Once I’ve logged into Dropbox, I can quickly get my new MacBook editor and terminal set up just how I want them. I do this by creating local symbolic links to the configuration files in my Dropbox.

$ cd ~
$ rm -rf .oh-my-zsh
$ ln -s Dropbox/Terminal/.oh-my-zsh/ .oh-my-zsh
$ rm -f .zshrc
$ ln -s Dropbox/Terminal/.zshrc .zshrc
$ ln -s Dropbox/Terminal/shell_scripts/ shell_scripts
$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/
$ rm -rf Installed\ Packages
$ rm -rf Packages
$ rm -rf Pristine\ Packages
$ ln -s ~/Dropbox/Sublime\ Text\ 2/Installed\ Packages Installed\ Packages
$ ln -s ~/Dropbox/Sublime\ Text\ 2/Pristine\ Packages Pristine\ Packages
$ ln -s ~/Dropbox/Sublime\ Text\ 2/Packages Packages

Now, when I run iTerm 2 and Sublime Text 2, both pick up their configurations from Dropbox. In Sublime’s case, this includes all installed packages too. So, at this point, I can get into coding without any further delay.

OS X Terminal
My OS X terminal - iTerm2 (showing Z shell, Oh-My-Zsh, fortune and Archey).

Apache

Apple wisely include Apache with OS X. But it does not run out-of-the-box. The first thing I do is create a web-root in my home directory then symlink all the Apache configuration files into that directory: so I don’t have to think too much when I have to manage hosts, or change the way Apache runs:

$ mkdir ~/webroot
$ cd ~/webroot
$ ln -s /private/etc/hosts hosts
$ ln -s /private/etc/apache2/httpd.conf httpd.conf
$ ln -s /private/etc/apache2/other/httpd-vhosts.conf vhosts.conf

Then, once I’ve configured these three files, I can start Apache with:

sudo apachectl start

If there are no errors in the configuration then Apache will now start. Once started, the Apache instance seems to be persistent (it survives reboots) so, if we need to stop it, we’ll have to do so manually:

sudo apachectl stop

nanoc

I then needed to install nanoc and its dependencies so that I would be able to manage this website. This couldn’t be any simpler, relying only on the installation of a collection of Ruby Gems:

$ sudo gem install activesupport adsf anemone atomic bluecloth builder bundler bundler-unload celluloid chronic chunky_png coderay coffee-script colored commonjs compass cri erubis excon execjs executable-hooks ffi formatador gli guard guard-nanoc haml image_size kramdown log4r mime-types multi_json net-scp posix-spawn pygments.rb rdiscount RedCloth rubygems-bundler rubypants stringex terminal-notifier-guard typogruby wraith

Final Steps

At this point, all that remained was to complete the migration of data from the old MacBook to the new. I did this with a USB-3 external hard disk and a liberal dose of tar.gz. The most time-consuming part of the whole process was migrating my iPhoto library. Of course, there were preferences to configure for the installed applications and other minor configuration tasks. But the computer was up and running, quicker than I’d ever thought possible and with all of the garbage stripped away. That’s a win.

Participate in the discussion on Hacker News…

  1. I was an OS 9.2.2 stalwart for a long time. ↩︎

  2. Apache, lighttpd, and nginx↩︎

  3. Perl, PHP, Ruby and C. ↩︎

  4. I wanted to write this as soon as I got my MacBook configured but life, work and the 2014 FIFA World Cup — the best World Cup I can remember, despite England’s early exit — got in the way. ↩︎

  5. I wrote these instructions when my computer was running OS X 10.9 Mavericks. Some of the instructions may not work on other versions of the operating system. ↩︎

  6. I’m never without an Internet connection. When I’m away from home I have an unlimited data plan on my iPhone, with tethering. ↩︎

  7. These include Apple’s strict sandboxing rules, the hit-and-miss approval process and the 30% “Apple Tax”, all of which have resulted in some frustrated developers. ↩︎