Skip to content

Instantly share code, notes, and snippets.

@craigds
Last active May 24, 2021 08:45
Show Gist options
  • Save craigds/1582604 to your computer and use it in GitHub Desktop.
Save craigds/1582604 to your computer and use it in GitHub Desktop.
Mac development for Ubuntu users

Mac development for Ubuntu users

This is a quick summary of tweaks to make development on a Mac easier for Ubuntu users. These all worked on my Macbook Air with OSX 10.7 Lion.

If you have something to add here, please let me know! http://twitter.com/craigds

1. Install Xcode

Xcode is like build-essential, but for your mac. It includes gcc, make, etc. You can get it via the App Store for free.

2. Install homebrew and pip

See http://mxcl.github.com/homebrew/

homebrew is like apt-get. It doesn't have everything, but has enough to make it very handy. Requires Xcode since it builds things locally.

Install pip to make installing the below python packages easy. You can get it from http://pypi.python.org/pypi/pip

3. Map /Users to /home

If you're dealing with both Ubuntu and OSX machines, this will make config files etc a bit more portable:

sudo nano /etc/auto_master
# (comment out the /home line, and Ctrl-X to save the file)
sudo automount -vc
sudo rmdir /home
sudo ln -s /Users /home

4. Fix python readline

The default OSX python readline library is broken, and behaves weirdly when you tab-complete in ipython. Install the better one using pip:

sudo pip install readline

# pip doesn't actually preclude the system readline in sys.path, so we can move the old one out of the way instead
cd /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
sudo mv readline.so readline.so.bak

See the following thread for more information: http://stackoverflow.com/questions/726449/installing-ipython-with-readline-on-the-mac

5. Make a sane .inputrc

Macs have a weird readline configuration, meaning navigation in terminal is a right pain. Among other things:

  • Alt+Left doesnt move one word to the left like you expect it to. Instead it types some weird characters.
  • Typing a command and then pressing Up doesn't jump backwards in history properly (it goes to the last command, rather than the last one that starts with the characters you just typed)

Put this in your ~/.bashrc:

INPUTRC=~/.inputrc

And then create an ~/.inputrc file with ubuntu-ish defaults:

set bell-style visible
set expand-tilde on
set convert-meta off
set input-meta on
set output-meta on
set show-all-if-ambiguous on
set visible-stats on

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[1;9D": backward-word
"\e[1;9C": forward-word

6. Install htop

If you're used to the GNU top program, the OSX equivalent is really crippled and useless. You can't even choose a sort column. I recommend using htop instead. It's not quite the same as GNU top, but it's arguably even more powerful:

brew install htop-osx
sudo ln -s `which htop` /usr/local/bin/top

I found /usr/local/bin was after /usr/bin in $PATH (??) so I added this to my ~/.bash_profile to fix it:

if [ -d /usr/local/bin ] ; then
    PATH=/usr/local/bin:"${PATH}"
fi

7. Open apps from the command line

Symlink common apps. Each app has a bin file somewhere:

sudo ln -s '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' /usr/local/bin/s

man open for other ways to open apps.

8. Symlink updatedb

updatedb is pretty well hidden in OSX. Might as well symlink it to somewhere sane:

sudo ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment