Code or Die Welcome to my kitchen

Setting Up

I recently reinstalled Mac OS X from scratch and had to reconfigure all the little tweaks that had made my development workflow easier. These were settings that I had not noticed previously since they were so ubiquitous. Now that they were gone I felt naked and powerless on my clean install.

Setting out to reconfigure my settings, it was immediately noticeable that there were quite a few special details I had forgotten about, therefore I am posting this mostly as a ‘note to self’. If anyone stumbles upon this information, then I hope they gain some inspiration to customize their development environment as they see fit. Please keep in mind these are my own preferences and your mileage may vary.

Credit goes out to Mike Busch for giving the instructions upon which most of the steps below are based. Thanks Mike!

Mike’s Environment Linter “helps identify issues with OS X machine setup for basic web development with Ruby.” After running through the steps, go ahead and check the results with it, (for example my laptop for some strange reason had both rbenv and rvm, which is not recommended. I stuck with rbenv.)


  • Mac with OS X Mavericks or later, (I am on OS X Yosemite 10.10.)
  • Sublime Text 3
  • Dropbox (to sync text editor settings between multiple machines.)
  • Terminal - Later on we can get fancier with our Terminal program, but for now the default OS X Terminal will work just fine.
  • Google Chrome with Web Developer extension. I could make an entire post just about browser extensions, but this one is most relevant to my developer toolbox.

Again, these are the just the tools I like to use, so be sure and use your own preferred browser or text editor.


Install Command Line Tools

From Terminal:

$ xcode-select --install

Configure Sublime Text from the command line, subl.

According to the docs, this command is configured to run from ~/bin directory on your home user directory, which is a bit messy for various reasons. The following alternate instructions were gleaned from this gist.

In summary, from Terminal type: echo $PATH to check if /usr/local/bin directory appears. Due to the “clean install” of OS X, either it is not in the $PATH or the folder does not actually exist. This means we have to create it first if we wish to follow the instructions from the above gist. This has occurred to me on both Yosemite and El Capitan clean installs.

If the folder does not exist, type mkdir -p /usr/local/bin from your user root directory using sudo if privilege is required. I ran into some trouble with this by accidentally entering Sublime Text 2 command and somehow creating a bin file instead of folder in /usr/local. As always with sudo and rm, it is definitely a task to do slowly and mindfully. In my case I had to explicitly cd into /usr/local to create the /bin directory using sudo, after rm the erroneous bin file. Others have reported deleting the symlink and recreating it fixed errors on this. Your Mileage May Vary.

Here is how to find the subl command location, symlink and check it(note these are for Sublime Text 3.):

$ find /Applications/Sublime\ -name subl

The preceding gives the path to subl. Use it in the next command.

$ ln -fs "/Applications/Sublime" /usr/local/bin/subl

Test in the Terminal subl -h. It should pop up some basic helpful commands. If so, you will now be able to open files and project folders in Sublime Text.

Finally, I modified my $PATH variable to prioritize /usr/local/bin: (I used the vim-like built-in bash text editor nano to be cool.)

$ sudo nano /etc/paths

(The following is a great command to alias):

$ echo $PATH | tr : '\n'



So now my /usr/local/bin is first in line along the $PATH environmental variable. Later on as dotfiles start piling on, there may be more changes but for now, this is good enough to start.

Bash profile and UNIX environment

Coming from a Linux background, configuring one’s environment should be a familiar task. Luckily there is an huge source of information online if we are not sure where to begin.

Topher Lubaway has a neat group of UNIX/bash environment setup files, (also known as dotfiles,) located here. It includes some nice prompt coloring for git branch changes along with other nifty details, and I am partial to them since using them extensively. Thanks Topher!

Dotfiles are a source of pride for many developers and they are shared extensively. Check out for more examples and tutorials. It is a tremendously helpful resource.

Follow all the instructions from Topher’s dotfiles repo including setting GitHub username and password, or just edit ~/.bash_profile and ~/.bashrc as you see fit. When choosing to use Topher’s dotfiles be aware Ruby gem awesome_print will be required when you open IRB sessions, but we can deal with that later.

Something that I like to change from Topher’s dotfiles are the Sublime Text key-bindings and preferences, but this could be a whole other future post so we won’t go into it at this time.

While we’re are at it, might as well add any alias commands we want and fancy ASCII art greetings when firing up a Terminal session. Get silly.

Run source ~/.bash_profile or exit and relaunch Terminal to confirm changes.


Since we have a clean install, we will need to install Homebrew. Run this command in the newly configured Terminal:

$ ruby -e "$(curl -fsSL"

Staying true to the craft means we need to keep our tools in tip-top shape. Update Homebrew:

$ brew update

And make sure it is happy:

$ brew doctor

Fix any error messages until “Your system is ready to brew.” appears.

Make sure that our system is using Homebrew’s installed packages.

Run this command to output our $PATH variable in a more legible format:

$ echo $PATH | tr : '\n'

And check that /usr/local/bin comes before both /usr/bin and /bin.

If we used the above dotfiles, it should. If not, open ~/.bash_profile and add: export PATH="/usr/local/bin:$PATH"

Install sqlite3 with Homebrew

$ brew install sqlite3

Force OS X to use this version of sqlite3 and not the one that comes pre-installed:

$ brew link sqlite3 --force

Install postgres with Homebrew

$ brew install postgres

Since postgres requires a server with which to interface, we use OS X’s launchd utility to keep this server running. Execute these two commands:

$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

If all goes well, run which postgres to confirm the location is /usr/local/bin/postgres.

We can also check that postgres server is running by entering this ps or process status command:

$ ps aux | grep postgres

Finally, create a default database and test our postgres client, psql.

$ createdb $USER

$ psql $USER

This last command opens the sql console for the default database.

Install a Ruby Manager with Homebrew

I prefer to use rbenv. There are other options, notably rvm. Choose one and stick to it.

brew install ruby-build rbenv

If we used rbenv and Topher’s dotfiles from earlier, go ahead and comment or delete out the lines of code that use rvm in ~/.bash_profile, ~/.bashrc and ~/.profile if they appear.

Install Ruby using a Ruby Manager

$ rbenv install --list

This will list all of the Rubies ruby-build can install. Choose one, likely the latest non-development build. For example:

$ rbenv install 2.2.3

And finally set the global/shell/local ruby:

$ rbenv global 2.2.3


$ which ruby

To make sure we are not using the system’s pre-installed Ruby. It should say something like this: /Users/Nyc/.rbenv/shims/ruby

$ rbenv which ruby

Restart the Terminal.

Install git with Homebrew

$ brew install git

Make sure we’re using git from Homebrew:

$ which git

Should give: /usr/local/bin/git

If we didn’t earlier, then set username, email for git.

$ git config --global "John Doe"

$ git config --global

Finally, set up Sublime Text as default editor for git:

$ git config --global core.editor "subl -w"

Install node with Homebrew

$ brew install node

Install Ruby gems

Make sure the load path is right.

$ which gem

Should yield, /Users/Nyc/.rbenv/shims/gem or similar.

$ rbenv which gem

Gives me: /Users/Nyc/.rbenv/versions/2.2.3/bin/gem

For good measure, update the existing gems:

$ gem update --system

Then install bundler:

$ gem install bundler

$ rbenv rehash


$ gem install sqlite3 pg nokogiri

If all goes well, run both:

$ gem install awesome_print

$ gem install rspec

Restart the Terminal application.

Install bash using Homebrew

Last but not least, let’s update our most likely woefully out of date default installation of bash. See the current version running with:

$ bash --version

To install:

$ brew install bash

We need to add this version to /etc/shells.

$ sudo -s "echo /usr/local/bin/bash >> /etc/shells"

And change the shell command:

$ chsh -s /usr/local/bin/bash

Quit Terminal completely, and restart a new Terminal session. Confirm the version has been updated.


After this initial setup, I like to customize the text editor and use an alternate Terminal program like iTerm, OS X settings and whatnot, but I think I might save that for another post.

Something that I learned while posting this is that creating your own personal dotfiles absolutely simplifies the process of getting a development environment up and running quickly - especially if you have many workstations!

Feel free to reach out to me on Twitter or email if I missed anything. Feedback is always welcome.