Caps Lock + Tmux

Nothing. But beyond that, without rebinding, the location and function of caps lock on a modern keyboard is more than inconvenient – it’s actively destructive. Enabling caps lock during a Vim session in normal code causes all hell to break loose, and what’s going on isn’t obvious unless you’ve seen the symptoms before.

I was pleasantly surprised to find that in OSX you can now disable caps lock out of the box if you don’t intend to rebind it. This is accomplished via System Preferences --> Keyboard --> Modifier Keys --> Caps Lock Key --> No Action, and provides a measurable improvement over the system default.

Then I started to wonder whether I could put caps lock to good use by solving another problem caused by Apple’s keyboard design, and the answer turned out to be yes.

Caps Lock as Tmux Prefix

Tmux has moved beyond a terminal multiplexing tool and has become one of the most important tools in my kit by acting as the de facto window manager for all my important tools and sessions. As such, I hit my Tmux prefix shortcut C-a a lot, which is tremendously inconvenient because even in 2012 Apple is still jamming a fn key onto everything they make so that ctrl is harder to hit.

Switching to caps lock as a Tmux prefix solves this problem forever. Here’s how to do it:

  1. Download PCKeyboardHack, install, and restart.

  2. From the new System Preferences pane, change the keycode under the Change Caps Lock entry to 109 (that’s F10), and check its box.

  3. In your .tmux.conf, change applicable settings to use F10:

    # thanks to PCKeyboardHack, F10 is caps lock and caps lock is F10
    set-option -g prefix F10
    
    # go to last window by hitting caps lock two times in rapid succession
    bind-key F10 last-window
    

Posted on August 19, 2012 from San Francisco

About

My name is Brandur. I'm a polyglot software engineer and part-time designer working at Heroku in San Francisco, California. I'm a Canadian expat. My name is Icelandic. Drop me a line at brandur@mutelight.org.

Aside from technology, I'm interested in energy and how it relates to our society, travel, longboarding, muay thai, symphonic metal, and the guitar.

If you liked this article, consider finding me on Twitter.