The Linux User’s OS X Survival Guide

(Or… how to get work done on a Mac if you’re a Linux junky.)

While normally a Linux user, my current employer has very kindly (and through great institutional effort) supplied me with a gorgeous MacBook Air. I was a Mac user about eight years ago (OSX Tiger!), but switched to Linux full-time a couple years after that, when I realized I just felt more productive in that environment.

The few can’t live without ’em features for me in Linux include:

  1. Remapping CapsLock to Esc (for vim).
  2. The select to copy, middle click to paste clipboard.
  3. Middle click to open a new browser tab.

We’ll tackle them one-by-one.

Remapping CapsLock to Esc in OS X

You’ll need PCKeyboardHack for this one. It will allow you to change the code generated by the CapsLock key. Set it to 53. The PCKeyboardHack site also says you should go in the OS X system preferences (System Prefs. > Keyboard > Modifier Keys) and set the CapsLock key to “No Action” to avoid experiencing a delay, although I didn’t find it necessary and haven’t noticed any sluggishness.

Emulating Linux’s Select/Copy Middle-Click/Paste

This little-known feature is totally a killer app. One-handed copy and paste with no keyboard input needed. Alternatively, if your hand ends up away from the mouse, you can also hit Shift-Insert to paste from Linux’s special clipboard. I am lost without it. The directions I found online are a bit confused, but after some trial and error, I got it working: select and three-finger tap to paste in iTerm2.

First, you need to set up the association between three-finger tap and middle click in iTerm. Go to iTerm > Preferences > Pointer. At the bottom, under “Miscellaneous Settings” check the box “Three-finger tap reports middle click to apps.” But that alone doesn’t seem to do the trick. In order to get this working, I had to install and keep MiddleClick (for Mountain Lion) running in my system tray.

Two-finger drag to select still has horrible performance in iTerm, however. Please tweet at me if you have an answer for that!

Three-Finger Tap to Open a New Browser Tab

Surprise! This one got fixed as a side-effect of installing MiddleClick. You’re welcome. 🙂


I am writing this post about a month after resolving these issues, so please let me know if anything here didn’t work out for you, and I will investigate my system settings further.


Thanks to my friend Eric Mill for the idea for the name of this post.

Installing OpenGrok on Ubuntu (Java Target Version Error)

Earlier today, I installed Solr on top of OpenJDK 1.6, running Tomcat 6. That went just fine, but I ran into trouble later, when I tried to install OpenGrok, which requires JDK 1.7. When I ran ant, I got this error:

-do-compile:
[javac] Compiling 245 source files to /usr/local/src/OpenGrok/build/classes
[javac] javac: invalid target release: 1.7

This was strange, since at the suggestion of this StackOverflow answer, I put this line after my opening <project> tag of build.xml

And the result was that I was already running 1.7. After a lot of trial and error, I got it to work by running update-alternatives to officially set the java version to 1.7.

sudo update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

Hopefully this can help out some other Java sysadmin neophytes.

Installing PyCUDA on Ubuntu via pip

I’m currently configuring an Ubuntu server with an NVidia Tesla GPU unit.

In the interest of actually getting things done with it, we are going to try out the PyCUDA library.

The PyCUDA Installation Docs for Linux don’t refer to installation via pip, but I wanted to give it a try. It mostly went without a hitch, except for a couple of things.

You’ll need to make sure that the cuda bin directory is on the system path.

export PATH=/usr/local/cuda/bin:$PATH

Then you’ll need to install numpy, which also requires having Python’s dev package installed.

sudo apt-get install python-dev
pip install numpy

At this point, if you run

pip install pycuda

You will get an error:

In file included from src/cpp/cuda.cpp:1:0:
src/cpp/cuda.hpp:12:18: fatal error: cuda.h: No such file or directory
compilation terminated.

This had me confounded, partially due to pycuda’s frequent exhortations in the install logging to run the configure script and Ctrl-C if certain things weren’t what I wanted, etc. But most of the warnings were moot, since pip removes the build directory if you cancel the install (I’m sure there’s some way around this), blocking manual access to the configure script, and there did not seem to be a way to pass configure flags through pip (would also love to learn if you can do this). But then I found this little gem at the beginning of the Ubuntu-flavored install docs:

> You’ll need $CUDA_ROOT set to the root of the CUDA install directory

Set CUDA_ROOT and you should be good to go!

export CUDA_ROOT=/usr/local/cuda