Laptop Setup for an Awesome Development Environment

Laptop Setup for an Awesome Development Environment

We’ve published guides in 2009, 2011, and 2012 for setting up your Mac OS X laptop as a Ruby on Rails development machine. Many others have published and shared similar tutorials.

Instead of copying and pasting a series of steps from a blog post, a better approach is to leverage automation and the open source community to save time and get a more stable result.

For the past three years, we’ve been developing and maintaining Laptop, a shell script which turns a Linux or Mac OS X laptop into an awesome development machine.

Mac OS X

After setting up the prerequisites described in the project’s README, we run one line:

bash <(curl -s https://raw.githubusercontent.com/thoughtbot/laptop/master/mac)

Linux

There are no prerequisites for Linux except that we must use a supported version of Ubuntu (currently Trusty Tahy, Saucy Salamander, and Precise Pangolin), Debian stable (currently Wheezy), or Debian testing (currently Jessie).

Given a supported version, it is also one line to set up a Linux machine:

bash <(wget -qO- https://raw.githubusercontent.com/thoughtbot/laptop/master/linux)

How it works

Either script should take less than 15 minutes to install (depends on the machine).

The linux and mac scripts are short. They are intended to be human-readable so that we know exactly what is installed and idempotent in case an error requires the script to be run two or more times.

What it sets up

Laptop currently sets up these common components:

  • Zsh for the Unix shell
  • A systems package manager (Aptitude or Homebrew)
  • A Ruby version manager (rbenv)
  • A Ruby installer (ruby-build)
  • The latest stable version of Ruby
  • A Ruby package manager (Bundler)
  • A JavaScript package manager (NPM)
  • Our most commonly-needed databases (Postgres and Redis)
  • ImageMagick for cropping and resizing images
  • Qt for headless JavaScript testing via Capybara Webkit
  • A fuzzy finder (The Silver Searcher)
  • A terminal multiplexer (tmux)
  • A dotfile manager (rcm)
  • CLIs for interacting with GitHub and Heroku

Extending the script

Individuals can add their own customizations in ~/.laptop.local. An example ~/.laptop.local might look like this:

#!/bin/sh

brew tap caskroom/cask
brew install brew-cask

brew cask install dropbox
brew cask install google-chrome
brew cask install rdio

The ~/.laptop.local script can take advantage of the preparation the Laptop script does, such as its shared functions and exit trap, to provide better script output and aid debugging.

Vagrant boxes

We publish Vagrant boxes for each supported Linux distribution. These boxes have the Laptop script applied and ready to run. Setup looks like this:

vagrant init thoughtbot/ubuntu-14-04-server-with-laptop
vagrant up
vagrant ssh

We currently supply these Vagrant Cloud boxes:

thoughtbot/debian-wheezy-64-with-laptop
thoughtbot/debian-jessie-64-with-laptop
thoughtbot/ubuntu-14-04-server-with-laptop
thoughtbot/ubuntu-13-10-server-with-laptop
thoughtbot/ubuntu-12-04-server-with-laptop

Vagrant >= 1.5.0 is required to use Vagrant Cloud images directly.

What’s next?

After using Laptop to set up a development machine, a great next step is to use thoughtbot/dotfiles to configure Vim, Zsh, Git, and Tmux with well-tested settings that we’ve evolved since 2011.

Our dotfiles use the same ~/*.local convention as the Laptop script in order to manage team and personal dotfiles together with rcm.

Dan Croak Developer

Hound reviews Ruby and CoffeeScript code for style violations and comments on your GitHub pull requests. Free for open source repos.