Setting up a Brand New Mac for Development

Setting up a Brand New Mac for Development

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.

Goals

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.

View on GitHub

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.12 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.

Homebrew

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.

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

Mac App Store

The Mac App Store command line interface, or mas-cli, will allow you to install from the App Store.

brew install mas
Sign in

If you haven’t already logged into the App Store, you can do so now.

mas signin [email protected]

Brewfile

Now I’ll create a file called Brewfile in my main directory, which will list all the programs I want on the computer, and install them in a bundle.

Open Terminal, which will be in your home folder by default (/Users/you). Create the file.

touch Brewfile

You can edit the file with TextEdit, or by typing nano Brewfile. If you choose to edit with nano, you can save the file by typing Control + O to save, and Control + X to exit the file.

List of Programs

Here are all the programs I intend to install with a brief description. You can choose to add or subtract any programs you’d like. They’re all free.

Below are the entire contents of my Brewfile, which will install all the above programs with a single command.

tap 'caskroom/cask'

brew 'git'
brew 'node'
brew 'npm'

cask 'brackets'
cask 'flux'
cask 'firefox'
cask 'gimp'
cask 'google-chrome'
cask 'mamp'
cask 'opera'
cask 'spectacle'
cask 'sequel-pro'
cask 'vlc'

mas 'Numbers', id: 409203825
mas 'Pages', id: 409201541
mas 'Slack', id: 803453959
mas 'Sip', id: 507257563 
mas 'Simplenote', id: 692867256 
mas 'Todoist', id: 585829637

Now simply run this command to install the bundle.

brew bundle install

Bash

Config – ~/.bash_profile

Now that we have all our programs installed and Homebrew all nice and new, we should create a simple script to keep Homebrew up to date. I found this handy command on this Best of Homebrew gist.

First, create a .bash_profile dotfile in your home folder.

touch .bash_profile

We’ll create a bash alias to combine all the commands to keep Homebrew clean and up to date.

alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'

Run the following command.

source ~/.bash_profile

Now you can run brewup to update, upgrade, prune, cleanup, and doctor Homebrew. It’s a good idea to do this often, even daily.

brewup

GitHub

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.

touch .gitconfig

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.

[user]
    name = First Last
    email = [email protected]
[github]
    user = username
[alias]
    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
[credential]
    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.

SSH

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.

touch .ssh/config

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.

Host example
    HostName example.com
    User example-user
    IdentityFile key.pem

Now just run the alias to connect.

ssh example

Generate SSH key

You can generate an SSH key to distribute.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Node Package Manager

I have npm installed, and npm is mostly used locally for projects. The only thing I use globally at the moment is Gulp.

Gulp

Install Gulp globally.

npm install --global gulp-cli

Ruby Version Manager

Ruby is required to run Jekyll, a popular static site generator. I’m going to download rvm to make sure I have the updated version of Ruby without messing with the built-in system Ruby.

Download rvm

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

Install Ruby version

As of this tutorial on 12/28/2016, 2.3.3 is the most up-to-date version.

rvm install 2.3.3

Install bundler

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

Virtual Hosts

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.

Preferences

I have a few preferences I like to set.

A few more commands to change some defaults.

Show Library folder

chflags nohidden ~/Library

Show hidden files

defaults write com.apple.finder AppleShowAllFiles YES

Show path bar

defaults write com.apple.finder ShowPathbar -bool true

Show status bar

defaults write com.apple.finder ShowStatusBar -bool true

Conclusion

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.

Written by Tania Rascia

12 Responses

Leave a Reply

Your email address will not be published.