I just got a new laptop, so I thought I would detail my work setup for those that care (most likely me next time I have to setup a laptop…). Sorry PC folks, but I find that if I am going to work, I do so exclusively on OS X at this point.
System Setup
iTerm2: The first thing I always install is iTerm2. It is a terminal emulator that I prefer to the default terminal that ships with OS X. After downloading it, make sure to manually check for updates the first time to get the latest bits. I prefer to use docked terminal windows but always forget how to set that up. To do so, under the “Profiles” tab of the Preferences screen, in the Windows section change the style to “Top of Screen”.
Homebrew: I can’t reccomend Homebrew enough. If you are installing packages manually, or even worse, using Mac Ports, then Homebrew will change your life. To install it just run
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
from any terminal window and follow the on screen prompts. Once the installation is complete, update your brew recipes with
brew update
XCode: If we want brew to actually work, we will need to install the Command Line Tools for XCode so that we can actually compile things from source. To do so you will need to go to Apple’s Developer Center. Download the command line tools appropriate for your operating system.
ZSH: Next I install ZShell in place of the default Bash shell. You can do this with:
brew install zsh
After the installation is complete set ZSH as your default shell with the following command
chsh -s /bin/zsh
Next install Oh-My-ZSH. Check out the github repo for more info, but you can use the automatic installer
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
To customize your prompt, edit the ~/.zshrc file. I normally change my theme to nebirhos, but any theme that has good git/rvm integration will work well. At the end of your .zshrc file you can also set the plugins to include. I normally use
plugins=(brew bundler cap gem git git-flow osx pip pow rails rails3 ruby rvm sublime)
Git: While you already have git installed by default, I like to manage my version of git with brew. So install it
brew install git
Note that you may need to change the order of your path variables. After your installation is done, try
which git
and if it returns anything other than /usr/local/bin/git then make sure that the first entry of your path variable is /usr/local/bin in your .zshrc file. This will ensure that brew installed binaries are used.
Academic Work
Sublime Text 2: Sublime Text 2 is my go to for doing any type of code editing or authoring. I am a somewhat recent convert (from Textmate), but glad to have made the switch. It is Python based, so it can be configured using Python. Similarly, all of the plugins are written in Python so it is easy to customize.
The first few things to setup after you get Sublime installed are: Package Control for easier package management (just press cmd+shift+p and type ‘install’ to access it), and of course your theme. I am a big fan of Solarized (Dark).
To run R or Python code from Sublime I use the SublimeREPL package.
LaTeX: First install MacTex so that you have the command line tools to build latex documents. It is big (around 2GB). Additionally, install Skim if you want a PDF reader that integrates nicely into this setup.
Next install the LatexTools package for Sublime Text 2. This will give you everything you need to build from ST2 by pressing Cmd+B
Python: While OS X ships with a version of Python installed, I manage my Python installations with brew. For some of the advantages of doing it this way, see this wiki article.
brew install python
Open a new terminal tab and install any python packages that you will need, e.g.
pip install tweepy
Installing scipy and matplotlib can sometimes be a pain, so again I try to use homebrew to accomplish this. First you will need to tap some external homebrew recipes, and then you will need to install some prerequisites:
brew tap samueljohn/python brew tap homebrew/science brew install gfortran pip install nose brew install scipy brew install matplotlib
When you are all done, open a python console and check that you can import scipy and matplotlib to verify.
R: Before we can install R, we must first install XQuartz so that R can draw its graphs. After XQuartz is done installing (just use the dmg), you can install R using brew
brew install R sudo ln -s "/usr/local/opt/r/R.framework" /Library/Frameworks
Development
RVM: I use RVM to both handle compiling different Ruby versions as well as create project specific gemsets. I’ve heard good things about rbenv, but thus far seen no reason to switch. I also like to set my system ruby to 1.9.3
curl -L https://get.rvm.io | bash -s stable --ruby rvm install 1.9.3 rvm use 1.9.3 --default
The above should install rubygems by default. Using that you can install Bundler.
gem install bundler
Some versions of Ruby may require the autoconf library which is not installed by default. To make sure that you can build these install it first
brew install automake
SSH Keys: In order to securely interact with github and other remote servers we ned to set up SSH keys for our machine. Github has a good tutorial here.
cd ~/.ssh ssh-keygen -t rsa -C "you@youremaildomain.com"
Git-Flow: For my development projects (especially web based ones) I like to use git-flow. Read more about it on the website, but it is a simple, logical way to manage branching for applications that need to remain relatively stable.
brew install git-flow
Postgres: Use brew to install postgres on your local machine. Follow the instructions at the end of the installation if you would like postgres to start when you restart your machine. I also create a ‘rails’ user for my local rails apps.
brew install postgres initdb /usr/local/var/postgres -E utf8 createuser rails -s
If you want a GUI to interface with the DB check out pgAdmin.
POW: To run rails applications locally I use POW. This allows me to run my rails apps at somedomain.dev by just adding a symlink in the ~/.pow directory.
curl get.pow.cx | sh
ElasticSearch: I find that ElasticSearch is my current default for fulltext search needs. It is Lucene based and really easy to work with.
brew install elasticsearch ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Useful Apps
Dropbox: I use Dropbox for syncing and sharing files between my machines. I am trying to get my colleagues to move away from Dropbox as a coauthoring technique and rely on distributed source control, but occasionally use it for that as well.
1Password: For storing, syncing and generating credentials across my various machines I use 1Password. When used in tandem with dropbox it is easy to use lengthy random passwords for all of my various accounts without memorizing (or even knowing) them.
Skitch: For getting screenshots and annotating them I still use Skitch.
MailPlane: Almost all of my email accounts are Gmail based, so I use MailPlane to manage them. You get the gmail interface but some nice extra features as well.
Skype: For video chat and screen shares I use Skype. It’s free and it works.
That is it for now. With all of this installed, I can finally get back to work….


