/ osx

Setting Up a New Mac for Development

Latest Update: May 26th, 2016

Table of Contents

  • Command-Line Utilities
    • Homebrew
      • Installing Brew
      • Brew Troubleshooting
    • Installing the latest Java JDK
      • Where is JAVA_HOME?
    • Setting up your SSH keys
      • Share your public key
    • Fixing your Git settings
      • Set your core Git editor to the one you're most comfortable with
    • Other Developer Utilities
      • Ruby
      • PHP
  • OSX Applications
    • Text Editors and IDEs
      • Sublime Text

Command-Line Utilities


An absolute must. If you have ever worked with apt-get on Ubuntu, you know that it's the absolute developer bliss. Homebrew (or brew for short) is the missing package manager for OSX. Not only does it allow you to install/unisnstall/manage software with a few simple commands, the same way that apt-get does. It allows you to access and install ports of most of the cross-platform utilities that you might be familiar with from Linux, over to OSX.

Installing Brew

Simply open a new terminal and execute the following command:

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

Brew Troubleshooting

Apps installed via Brew are overriden by others, already provided on your Mac

I installed the latest version of Git using brew, but still, when I execute git --version, it shows me the already outdated one that comes with the Mac CLI tools. How do I fix this?

The problem might lie in the fact that /usr/bin occurs /usr/local/bin in your $PATH variable. Make sure to correct the order in your ~/bash_profile file:

export PATH="/usr/local/bin:$PATH"

Installing the latest Java JDK

Most certainly your OS X comes with an outdated Java version or no Java at all. In any case, you sure need to install the latest one.

Where is JAVA_HOME?

If you don't see the JAVA_HOME environment variable, don't worry. You can easily set it, without having to know the exact path to your JDKs location. Add the following to your ~/.bash_profile file:

export JAVA_HOME="$(/usr/libexec/java_home -v <JAVA_VERSION>)"

Where JAVA_VERSION will most probably be 1.8, but could also be set to 1.7 or 1.6 (depending on which version you installed)

Setting up your SSH keys

SSH keys allow you to communicate with other machines or services, using an encrypted connection, and without having to type a password every time. Setting up an SSH key is highly recommended, if not even required by most services, used by developers: GitHub, Heroku, BitBucket, etc.

To generate a new SSH key, open a Terminal and type:

ssh-keygen -t rsa

and follow the instructions. By default, ssh-keygen will generate a private key id_rsa and a public one id_rsa.pub and put them in the ~/.ssh directory. You can, of course, decide to choose a different path and location for your key files. Keep in mind that if you do so, you would have to either explicitly tell applications where to look for your keys, or add configuration entires in your ~/.ssh/config file. Both ways will be explained in further sections.

Share your public key

One of the common uses of SSH keys is to connect to other machines, without having to supply a password. To be able to do so, you have to share your newly generated public key with the remote machine. Open a terminal and type:

cat ~/.ssh/id_rsa.pub | ssh <REMOTE_MACHINE_ADDRESS> "cat >> ~/.ssh/authorized_keys"

The above command will require your password once, then it will append your public key over to the ~/.ssh/authorized_keys file on the remote machine. The next time you log in to the remote machien via ssh, your password will no longer be required.

Fixing your Git settings

Whether Git comes preinstalled on your OS X, or you set it up separately, make sure to have a look at the default settigns that it comes with. There are a couple of important setting that you might need to set up yourselves. For instance, your name and email. If you commit to a collaborative Git repository, your email and name are used to identify your commits, and distinguish them from those of your peers. Therefore, make sure to check the following two settings:

git config --get user.name
git config --get user.email

and change them to appropriate values, if needed:

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Set your core Git editor to the one you're most comfortable with

Another setting you would want to have a look at, is your core Git editor. The default is set to vim. If you are like me, and you still haven't managed to really master those vim skills, you should look forward to changing it with something more lightweight, like nano, for instance:

git config --global core.editor <YOUR_FAVORITE_EDITOR_EG_NANO_OR_EMACS>

A text editor is used all over the place by Git, so, better make sure to check that out.

Other Developer Utilities


RVM (Ruby Version Manager)

RVM allows you to install and manage multiple Ruby environments on the same machine. This is really helpful, since often gems require a version of Ruby, different from the one that OSX gets shipped with.

Installing RVM

First and foremost, it is good to have Brew installed. You can use brew to install gpg - a security program used to check the security of the rvm download.

brew install gpg

Install the security key for rvm

command curl -sSL https://rvm.io/mpapis.asc | gpg --import -

And finally, rvm itself

curl -L https://get.rvm.io | bash -s stable



Composer is a dependency manager for PHP. It does the heaavy-duty job of automatically downloading dependency PHP libraries and organizing them in such a way that projects can use them right away. Composer is similar to Node.js' npm, Ruby's gem or Java's Ivy/Maven/Gradle (though Gradle and Maven are full-scale build systems. Downloading dependencies is just of the many things they're used for).

Installing Composer

Composer can be installed at a project level, or globally (at the user level).
Installing Composer locally:

$ curl -sS https://getcomposer.org/installer | php
# now, you can run Composer using php
$ php composer.phar

or globally (which is basically, moving composer.phar under //usr/local/bin/):

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
$ composer

## OSX Applications ### Text Editors and IDEs #### Sublime Text ##### Create a symlink to your Sublime app, for easy use within the terminal Sublime Text offers a command line tool called `subl`, which can be used to open files and projects within the terminal. It can be also used as the default editor in git and Subversion. To make use of this tool, all you need, is to create a symlink to it:
ln -s /Applications/Sublime\ Text\ 3.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

to be continued ...