Skip to content

Instantly share code, notes, and snippets.

@look4regev
Created October 15, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save look4regev/a48730aaee58b21d7f2d6fa9c4dc88f0 to your computer and use it in GitHub Desktop.
Save look4regev/a48730aaee58b21d7f2d6fa9c4dc88f0 to your computer and use it in GitHub Desktop.
Swap Mac ± and ~ keys script
# Taken from https://ppolyzos.com/2020/10/09/swap-places-between-tilde-and-section-sign-%C2%A7-key-in-your-macbook-keyboard/
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000064},{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
sudo /usr/bin/env bash -c "cat > /Library/LaunchAgents/org.custom.tilde-switch.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.custom.tilde-switch</string>
<key>Program</key>
<string>${HOME}/.tilde-switch</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
EOF
sudo launchctl load -w -- /Library/LaunchAgents/org.custom.tilde-switch.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment