Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created September 26, 2012 13:30
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save burtlo/3788048 to your computer and use it in GitHub Desktop.
Save burtlo/3788048 to your computer and use it in GitHub Desktop.
TMUX: Rebinding CAPS LOCK to CTRL + B

Disabling CAPS LOCK

If you haven't already done so, gain an extra key and open up your System Preferences > Keyboard > Modifier Keys ... and rebind CAPSLOCK to No Action.

Rebinding CAPSLOCK to CONTROL_R (Right Control Key)

  • Install PCKeyboardHack
  • Open System Preferences > PCKeyboardHack
  • Change "Caps Lock" to keycode 62.

Reassigning the Caps Lock

Rebinding CONTROL_R (Right Control Key) to CONTROL + B

  • Install KeyRemap4MacBook

  • Open System Preferences > KeyRemap4MackBook > Misc & Uninstall

  • Click "Open private.xml"

Opening private.xml

  • Copy and Paste the private.xml provided with in this gist.
  • Open System Preferences > KeyRemap4MackBook > Change Key
  • Click "ReloadXML"
  • Toggle open "TMUX Key Remappings"
  • Check "TMUX: Right Control to Control+B

Enabling Keybinding

<?xml version="1.0"?>
<root>
<appdef>
<appname>Terminal</appname>
<equal>com.apple.Terminal</equal>
</appdef>
<item>
<name>TMUX Key Remappings</name>
<item>
<name>TMUX: Right Control to Ctrl+B</name>
<identifier>private.right_control_to_control_b</identifier>
<only>Terminal</only>
<autogen>
--KeyToKey--
KeyCode::CONTROL_R,
KeyCode::B, ModifierFlag::CONTROL_L
</autogen>
</item>
</item>
</root>
@bradparks
Copy link

yeah! thanks dude.... this rocks!

@mahemoff
Copy link

mahemoff commented Apr 1, 2013

Awesome! If anyone's wondering why not to simply map Caps Lock to Ctrl-B , the answer is it doesn't work very well at all. It seems to require Caps Lock to be up before the other key is pressed, and even then, seems to require some delay. I assume this is why @burtlo did it this way.

Also, careful if using iTerm or other terminals; the XML will need to include them. See https://gist.github.com/mahemoff/5288473

@hanjianwei
Copy link

Awesome!

@infosniper
Copy link

PCKeyboardhack has been renamed. In Yosemite press command+space sail
KeyRemap4MacBook has been renamed to Karabiner. command+space karabiner
Thanks for this awesome tip

@dpo
Copy link

dpo commented May 7, 2015

Thanks! If instead of replacing your private.xml you just add

    <item>
      <name>TMUX: Right Control to Ctrl+B</name>
      <appendix>TMUX Key Remappings</appendix>
      <identifier>private.right_control_to_control_b</identifier>
      <autogen>
        --KeyToKey-- 
        KeyCode::CONTROL_R,
        KeyCode::B, ModifierFlag::CONTROL_L
      </autogen>
    </item>

to your existing private.xml, then it also works in iTerm.

@mahemoff
Copy link

mahemoff commented Jun 8, 2015

Seil is the new name for PCKeyboardHack (not Sail)

@mahemoff
Copy link

And Karabiner is the new name for KeyRemap4MacBook

@moulimukherjee
Copy link

This seems to be broken in mac Sierra. Any workarounds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment