Instantly share code, notes, and snippets.

@zbstof /remap.sh
Last active Dec 13, 2017

Embed
What would you like to do?
#!/usr/bin/env bash
# To run at startup:
# sudo defaults write com.apple.loginwindow LoginHook `pwd`/remap.sh
# https://developer.apple.com/library/content/technotes/tn2450/_index.html
CAPS_LOCK="0x700000039"
ESCAPE="0x700000029"
NON_US_BACKSLASH_PLUS_MINUS="0x700000064"
GRAVE_ACCENT_AND_TILDE="0x700000035"
SLASH_PIPE="0x700000031"
ENTER_RETURN="0x700000028"
RIGHT_SHIFT="0x7000000E5" #Do nothing button
FROM="\"HIDKeyboardModifierMappingSrc\""
TO="\"HIDKeyboardModifierMappingDst\""
hidutil property --set "{\"UserKeyMapping\":[
{$FROM: $CAPS_LOCK, $TO: $ESCAPE},
{$FROM: $ESCAPE, $TO: $RIGHT_SHIFT},
{$FROM: $GRAVE_ACCENT_AND_TILDE, $TO: $SLASH_PIPE},
{$FROM: $SLASH_PIPE, $TO: $ENTER_RETURN},
{$FROM: $NON_US_BACKSLASH_PLUS_MINUS, $TO: $GRAVE_ACCENT_AND_TILDE}
]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment