<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>dok</title>
 <link href="http://dknutsen.com/" rel="self"/>
 <link href="http://dknutsen.com"/>
 <updated>2014-07-12T10:08:43-07:00</updated>
 <id>http://dknutsen.com</id>
 <author>
   <name>Dan Knutsen</name>
   <email></email>
 </author>

 
 <entry>
   <title>OSX Development: Make OSX More Like Linux</title>
   <link href="http://dknutsen.com/code/2013/09/12/osx-development-making-osx-more-like-linux"/>
   <updated>2013-09-12T00:00:00-07:00</updated>
   <id>http://dknutsen.com/code/2013/09/12/osx-development-making-osx-more-like-linux</id>
   <content type="html">&lt;p&gt;This article assumes you like working with command lines unix tools and are completely comfortable – maybe even more comfortable – without GUIs.&lt;/p&gt;

&lt;h3 id=&quot;why_create_a_frankenos&quot;&gt;Why create a Franken-OS?&lt;/h3&gt;

&lt;p&gt;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… &lt;!--more--&gt; The good (not at all comprehensive):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OSX is built on Unix, so the file system and basic tools are very familiar and robust&lt;/li&gt;

&lt;li&gt;OSX is smooth, fast, beautiful, and just works really well&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bad (again, not comprehensive):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terminal app is outdated and all around pretty bad (though as bad as it is it’s still thousands of times better than the Windows console, no surprise there).&lt;/li&gt;

&lt;li&gt;Many of the other tools and commands are outdated if they are there at all.&lt;/li&gt;

&lt;li&gt;No default package manager. I mean there’s the App Store but let’s be serious&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good news though! Most of this can be fixed and you can have your cake and eat it too. Let’s get to it!&lt;/p&gt;

&lt;h3 id=&quot;first_things_first&quot;&gt;First things first&lt;/h3&gt;

&lt;p&gt;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&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3 id=&quot;homebrew_and_all_the_good_stuff&quot;&gt;Homebrew and all the good stuff&lt;/h3&gt;

&lt;p&gt;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 &lt;a href=&quot;http://brew.sh/&quot;&gt;Homebrew&lt;/a&gt;. 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.&lt;/p&gt;

&lt;p&gt;Homebrew installation is pretty straightforward. See installation, usage, and documentation at &lt;a href=&quot;http://brew.sh/&quot;&gt;brew.sh&lt;/a&gt;. 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 &lt;a href=&quot;https://github.com/mxcl/homebrew/tree/master/Library/Formula&quot;&gt;look at the package list&lt;/a&gt;. A few things I installed: vim (v7.4), ack and Ruby. Go wild!&lt;/p&gt;

&lt;h3 id=&quot;a_better_terminal&quot;&gt;A better Terminal&lt;/h3&gt;

&lt;p&gt;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 &lt;a href=&quot;http://www.iterm2.com/#/section/downloads&quot;&gt;iTerm2&lt;/a&gt;. 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!&lt;/p&gt;

&lt;p&gt;A few more things that I did (your mileage may vary):&lt;/p&gt;

&lt;p&gt;I changed my keyboard repeat settings so the terminal and vim move a little bit faster. To do that go to System Preferences &amp;gt; Keyboard and change the Key Repeat frequency.&lt;/p&gt;

&lt;p&gt;Installed ‘ack’ from Homebrew and aliased grep to ack in .vimrc (I do this on Linux too)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias grep=&amp;#39;ack&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Added an alias for ‘ll’ in .vimrc&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias ll=&amp;#39;ls -GFlh&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3 id=&quot;config_files&quot;&gt;Config files&lt;/h3&gt;

&lt;h5 id=&quot;accessible_anywhere&quot;&gt;Accessible anywhere&lt;/h5&gt;

&lt;p&gt;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 &lt;a href=&quot;http://dropbox.com&quot;&gt;Dropbox&lt;/a&gt;. 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.&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ln -sv ~/Dropbox/config/.gitconfig ~/.gitconfig
ln -sv ~/Dropbox/config/.bashrc ~/.bashrc
ln -sv ~/Dropbox/config/.vimrc ~/.vimrc&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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 &lt;a href=&quot;http://www.splitbrain.org/blog/2011-02/16-managing_dotfiles_with_dropbox&quot;&gt;splitbrain.org&lt;/a&gt; to auto-generate the symlinks. Awesome!&lt;/p&gt;
&lt;!-- future section with my config gists here
##### My config files
.ssh/config
.vimrc
.bashrc
--&gt;
&lt;h3 id=&quot;bonus_xcode_and_vim_make_a_baby_xvim&quot;&gt;Bonus: Xcode and vim make a baby, XVim&lt;/h3&gt;

&lt;p&gt;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 &lt;a href=&quot;https://github.com/JugglerShu/XVim&quot;&gt;XVim&lt;/a&gt; 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.&lt;/p&gt;

&lt;p&gt;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!&lt;/p&gt;

&lt;h3 id=&quot;tools_and_links&quot;&gt;Tools and links&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://brew.sh/&quot;&gt;Homebrew&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.iterm2.com/#/section/downloads&quot;&gt;iTerm2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://developer.apple.com/xcode/&quot;&gt;Xcode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://dropbox.com&quot;&gt;Dropbox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/JugglerShu/XVim&quot;&gt;XVim&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
 
 
</feed>