Skip to content

Instantly share code, notes, and snippets.

@rbreaves
Last active July 27, 2020 08:22
Show Gist options
  • Save rbreaves/b3b3a818f350cf10d3140c1a9b038242 to your computer and use it in GitHub Desktop.
Save rbreaves/b3b3a818f350cf10d3140c1a9b038242 to your computer and use it in GitHub Desktop.
Swap alt and cmd on macOS via Terminal
# Reference
# https://developer.apple.com/library/archive/technotes/tn2450/_index.html
#
# How to swap wordwise shortcuts to align with Windows/Linux
# http://benogle.com/2010/01/18/windowslinux-developers-remap-your-mac.html
# https://theconfused.me/blog/switching-between-mac-and-linux-keyboards/
#
# Swap cmd & alt to Windows/Linux style
# left cmd = e3
# left alt = e2
# right cmd = e7
# right alt = e6
#
hidutil property --set '{"UserKeyMapping":
[{"HIDKeyboardModifierMappingSrc":0x7000000e7,
"HIDKeyboardModifierMappingDst":0x7000000e6},
{"HIDKeyboardModifierMappingSrc":0x7000000e6,
"HIDKeyboardModifierMappingDst":0x7000000e7},
{"HIDKeyboardModifierMappingSrc":0x7000000e3,
"HIDKeyboardModifierMappingDst":0x7000000e2},
{"HIDKeyboardModifierMappingSrc":0x7000000e2,
"HIDKeyboardModifierMappingDst":0x7000000e3}]
}'
# Reset Keymap
hidutil property --set '{"UserKeyMapping":[]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment