12 September 2013
This article assumes you like working with command lines unix tools and are completely comfortable – maybe even more comfortable – without GUIs.
Coming from a Linux development background, when I started using OSX I found some things that were really great for development, but also some terrible… The good (not at all comprehensive):
The bad (again, not comprehensive):
Good news though! Most of this can be fixed and you can have your cake and eat it too. Let’s get to it!
To start off, we’ll need Xcode and the Xcode command line tools. If you’re doing iOS or OSX development you’ll want Xcode anyway. If you don’t have Xcode yet get the newest version from the App Store. It’s a big download so it will take a while. Go make yourself some coffee or read a short story or something
Next we want the Xcode command line tools. When you’re done installing Xcode start it up and then open Xcode preferences. In the “Downloads” tab find “Command Line Tools” and download them.
Now let’s install and upgrade some of our tools. Popular linux distros have excellent package managers like apt-get or yum, but with OSX we aren’t so lucky. There is a third party package manager however, and it turns out it’s pretty great. It’s called Homebrew. Homebrew will install all of the Linux utilities that you love and update some of the terribly outdated ones that OSX has. Just a disclaimer: Homebrew will (if you choose) install newer versions of OSX default tools like vim and Ruby. It worked fine for me, and should be foolproof, but this is messing with some lower level stuff so make sure you know what you’re doing.
Homebrew installation is pretty straightforward. See installation, usage, and documentation at brew.sh. Now let’s install some packages! What you install is really up to you so either start ‘brew install’ing off the top of your head or look at the package list. A few things I installed: vim (v7.4), ack and Ruby. Go wild!
If you’re used to linux, the OSX terminal sucks. Hard. Fortunately there is a fantastic alternative terminal emulator for OSX. Even better? It’s free. It’s called iTerm2. iTerm2 works just like the native Terminal app as far as I can tell so far and it’s fully customizable and has native OSX fullscreen support. Just install it and add it to your dock, customize your colors and other preferences and off you go!
A few more things that I did (your mileage may vary):
I changed my keyboard repeat settings so the terminal and vim move a little bit faster. To do that go to System Preferences > Keyboard and change the Key Repeat frequency.
Installed ‘ack’ from Homebrew and aliased grep to ack in .vimrc (I do this on Linux too)
alias grep='ack'
Added an alias for ‘ll’ in .vimrc
alias ll='ls -GFlh'
Made sure “Quit when all windows are closed” is checked in iTerm2 Preferences. You’ll also want to, in your default profile, change the “Working Directory” setting to “Reuse previous sessions directory” to make sure when you open a new tab it opens in the current directory.
There have been a number of times where I wanted to access my bashrc or vimrc on a different machine (my work laptop for example) and for a while my answer was to version control with github. This works reasonably well but is also annoying for a number of reasons and can potentially leave sensitive information exposed to the public. So what’s better? I like Dropbox. If you don’t have Dropbox you probably should. I personally have an upgraded plan because I keep all my important files in it but they also have free accounts with 2gb to start and up to 18gb for referalls.
Once you get Dropbox set up, make a folder in the Dropbox root and call it ‘sys’ or ‘config’ or whatever you want. Make backups of your config files in your home directory (just in case!) and then move them into your new folder in Dropbox. Then all you have to do is symlink them from your home directory. For example, from home directory:
ln -sv ~/Dropbox/config/.gitconfig ~/.gitconfig
ln -sv ~/Dropbox/config/.bashrc ~/.bashrc
ln -sv ~/Dropbox/config/.vimrc ~/.vimrc
Now you’ve got your config files in Dropbox and they can be shared between any of your machines and accessed from any device with an internet connection. If you want an easier way to set up a new machine using your existing Dropbox config files, use the handy script I found on splitbrain.org to auto-generate the symlinks. Awesome!
What if you can’t live without vim as your code editor but still want to write OSX/iOS apps in Xcode? There’s an answer to that too. It still has some rough edges, but XVim is an Xcode plugin that will give you vim keybindings right in Xcode. Follow the documentation for installation notes. At the time of writing the current version was in a beta branch. I also changed the Xcode colors too so it looks just like my vim environment. Would a lot of people cringe at it? Probably, but it’s what I like to code with. And that’s what this article is all about: making your development environment look like you want.
Those are the few of the things I’ve done to make my OSX machine more like Linux and I’m sure that’s just scratching the surface. Try them out and see what you get!