A walkthrough of techniques and sensible defaults for an Apple development environment.
I just got a new MacBook Pro, and I decided to research the fastest, most efficient method to set up a clean, organized, and up-to-date development environment for my new computer. I wrote about some of these steps in my front end web development setup post, and now I’m going to go into more detail.
I documented everything I did after taking the Mac out of the box. This post will be useful to anyone setting up a new Mac, whatever your preferred apps and settings are. Simply change variables as necessary.
I’m a front end web developer, and most of the software I install will pertain to that. I still have much to learn, but this process will setup my Mac to run Git, Jekyll, Gulp, Sass, an Apache server, and more.
I’ve included all the commands from this article without any of the explanation on a GitHub readme. Feel free to fork, modify, and keep for your own future records.
macOS Sierra v. 10.13 Setup
The Setup Assistant will launch once you turn the computer on. Here you’ll enter your language, time zone, Apple ID, and so on. I choose not to use “Migration Assistant”, and set up my computer from scratch. The first thing you should do is update macOS to get the latest security updates and patches.
If you’re setting up for the first time, you’ll have to install App Store software through the App Store itself, but if you’ve installed them before, you’ll be able to use Homebrew, Cask, and Mas to install all your programs from the command line.
Install the Homebrew package manager. This will allow you to install almost any app from the command line. In previous versions, you’d have to install XCode or Command Line Tools before using this, but that step is no longer necessary.
Now you can run brewup to update, upgrade, prune, cleanup, and doctor Homebrew. It’s a good idea to do this often, even daily.
Config – ~/.gitconfig
The first thing you should do with Git is set your global configuration. We can do this by running a lot of small commands which will update the Git configuration file.
git config --global user.name "First Last"
Or we can just create the Git configuration file and input it all ourselves.
Here I’ll input my name, email, GitHub username, some aliases to be able to type less and do more, and connect Git to the OS X Keychain so I don’t have to type my username and password every time I want to push to GitHub.
name = First Last
email = [email protected]
user = username
a = add
ca = commit -a
cam = commit -am
s = status
pom = push origin master
pog = push origin gh-pages
puom = pull origin master
puog = pull origin gh-pages
cob = checkout -b
helper = osxkeychain
With the above aliases, I can run git s instead of git status, for example. The less I have to type repeatedly, the happier I am.
If you use SSH (Secure Shell) to connect to any remote hosts via the command line, you can simplify the process.
Config – ~/.ssh/config
Create an SSH config file.
Add the following contents, changing the variables for any hosts that you connect to. Using the below will connect to -i key.pem [email protected]. You can remove the IdentityFile if you don’t connect with a pem key. The output will then simply be [email protected] and you’ll be prompted for password authentication.
I have npm installed, and npm is mostly used locally for projects. The only thing I use globally at the moment is Gulp.
Install Gulp globally.
npm install --global gulp-cli
Ruby is required to run Jekyll, a popular static site generator. I’m going to download Ruby Version Manager (rvm) to make sure I have the updated version of Ruby without messing with the built-in system Ruby.
\curl -sSL https://get.rvm.io | bash -s stable
Install Ruby version
You can look for and install the latest version by number, or by running the below command.
rvm install ruby-head
You can run rvm list to see the full list of versions available. To use the latest version, find the number and run this command.
rvm --default use 2.4.0
Confirm that you are using the latest version.
You can also test with which ruby, which will output your Ruby path and version number.
Gem is the Ruby package manager that we’re going to use to install bundler…a package manager. This is necessary to use Jekyll and useful for any other Ruby project.
gem install bundler
If you’re using MAMP like I am to set up an Apache/MySQL/PHP/Python/Ruby environment, here is a mini-tutorial on setting up virtual hosts.
I like to set a color scheme for my terminal. You can do this from Preferences, or by finding one online and opening the .terminal file, which will open a terminal with the new preferences. You can then save it as default. Add this to your bash_profile to enable colors in Terminal.
I also added something that will show what Git branch you’re on.
That sums it up for my current preferences on setting up a 2015 era MacBook Pro running macOS Sierra. I hope it helped speed up your process, or gave you ideas for the next time you’re setting up a new computer. This should set the groundwork for adding new software and processes in the future.
I know there is a lot I’m still missing. Some of my goals for 2017 involve setup with popular software like Vagrant, VirtualBox, Docker, and Ansible. If there’s anything you do differently, please feel free to let me know!
I also recently acquired an actual PC running Windows, so I can probably do some of my articles in a Windows environment upon request.