eprothro
8/15/2016 - 7:37 PM

general development machine setup.md

Now that you're a member of our github organization, let's get rolling:

Xcode

Download and install Xcode

Once Xcode is installed run the following in the terminal to install the OSX Command Line Tools:

xcode-select --install

Homebrew

A simple package manager to help install terminal applications you'll need with minimal headache.

Intall by executing the following into terminal:

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

Follow the instructions on the screen, the password it's asking for is the one for your computer :).

Git

Install the git client

brew install git

Setup your account with the git client

git config --global user.name "Your Name Here"
git config --global user.email "your_github_email@example.com"

Setup your ssh key for your development machine

If you've never created an ssh key on this machine, or you have no idea what that means:

ssh-keygen -t rsa -C "your_github_email@example.com" && eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa && pbcopy < ~/.ssh/id_rsa.pub

Just press enter each time you're prompted to use the defaults for where to put the key and the passphrase.

Go to your Github SSH settings page and add your key

  • Click Add SSH Key
  • For 'title', use a name indicating what machine this is, like Rocket Laptop
  • For 'key', paste the key (it was put on your clipbaord via pbcopy in the previous command)

Now, lets test it out:

ssh -T git@github.com

Type yes and press return if asked about continuing connecting.

This should yield the following:

Hi (your name)! You've successfully authenticated, but GitHub does not provide shell access.

Sweet, now you're set up to pull and push repositories of code with git to/from GitHub.

Pull a sample repository

Let's pull down the rocketmobile.github.io repository as a sample, to get started.

You'll need a place to keep all your repositories, we recommend somewhere close to root, like a source directory:

mkdir ~/source && cd ~/source

Now let's copy the repo from GitHub to our machine

git clone git@github.com:rocketmobile/rocketmobile.github.io

Now you can switch into the rocketmobile.github.io directory and poke around with this sample repo. Here we digress, as now isn't the time for a full fledged introduction on how to use git if it's new or newish to you.

A decent text editor

Install Sublime 2.

Set it up to be used from the command line and with git:

mkdir ~/bin
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
echo "export PATH=~/bin:/usr/local/bin:/bin:\$PATH" >> ~/.bash_profile && source ~/.bash_profile
git config --global core.editor "subl -w"

Optional: sample sublime configuration

A better terminal client

From here on, this is just if you're looking for what many of us use. Everyone is entitled to their configuration preferences -- this is just here in case you're looking for one :).

If you have no idea what the below is doing, that's fine, we re-cap it all at the end to explain your new rig.

Install iTerm2, using the last .zip link.

Now let's set up some git/bash fanciness.

brew install git bash-completion && curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

If you trust us, and don't know what you want in your bash profile:

curl -o ~/.bash_profile https://gist.githubusercontent.com/eprothro/ad8c128f7e065ad2c5ab/raw/.bash_profile.bash && source ~/.bash_profile

Or, if you'd rather do this manually, run subl ~/.bash_profile to open bash_profile in sublime, and paste in the following bash profile configuration, piecemeal or whole, save and close.

Now, a few more configuration properties for git:

subl ~/.gitconfig

Add or overwrite the following configuration, save, and close:

[color] 
  branch = auto 
  diff = auto 
  status = auto 
[color "branch"] 
  current = yellow reverse 
  local = yellow 
  remote = green 
[color "diff"] 
  meta = yellow bold 
  frag = magenta bold 
  old = red bold 
  new = green bold 
[color "status"] 
  added = yellow 
  changed = green 
  untracked = cyan 

And finally, reload your bash configuration:

source ~/.bash_profile

What the hell was all that?

Branch name in prompt

Now, when you switch into a git repository

cd ~/source/rocketmobile.github.io

You will see the current branch name in your command prompt (master, below).

[eprothro@mbp ~/source/rocketmobile.github.io (master)]$

You will see additional info about the git status as well (files added and modified, below)

[eprothro@mbp ~/source/wdh-engine (master *+)]$

Branch tab completion

When you checkout a branch, you can now press tab to auto-complete branch names, as with directories and filenames.

[eprothro@mbp ~/source/rocketmobile.github.io (master)]$ git checkout (tab, tab)
FETCH_HEAD      HEAD            ORIG_HEAD       master          origin/HEAD     origin/master