Summary
Adapting to the MacBook Pro's Command key-centric layout was challenging after years of using my ThinkPad X1 Extreme Gen 2. To avoid the transition, I started using Karabiner-Elements.
Karabiner-Elements lets you:
- Remap keys to match your muscle memory
- Create complex shortcuts
- Customise per-app layouts
About Karabiner-Elements Rule
I use another Simple modification to replace
Option
toCommand
with the Rule in this post.When you want to target a specific application to apply the keyboard manipulation, you need to figure out the value for
bundle_identifiers
called Bundle Identifier.You can find Bundle Identifier on the terminal as follows (
com.microsoft.VSCode
is it in this example), but it is easier to figure out withEventViewer
provided by Karabiner-Elements instead:
grep -A 2 "Identifier" /Applications/Visual\ Studio\ Code.app/Contents/Info.plist
======
<key>CFBundleIdentifier</key>
<string>com.microsoft.VSCode</string>
The File
.history | |
.vscode | |
save.sh |
{ | |
"title": "Use Option as Command for some applications", | |
"rules": [ | |
{ | |
"description": "Use Option as Command for some applications", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "tab", | |
"modifiers": { | |
"mandatory": [ | |
"right_shift", | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "open_bracket", | |
"modifiers": [ | |
"left_shift", | |
"left_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "tab", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "close_bracket", | |
"modifiers": [ | |
"left_shift", | |
"left_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "f", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "f", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_unless", | |
"bundle_identifiers": [ | |
"^com.googlecode.iterm" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "x", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "x", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "p", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "p", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "n", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "n", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "q", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "q", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "z", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "z", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_unless", | |
"bundle_identifiers": [ | |
"^com.googlecode.iterm" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "z", | |
"modifiers": { | |
"mandatory": [ | |
"right_shift", | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "z", | |
"modifiers": [ | |
"right_shift", | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "c", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "c", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_unless", | |
"bundle_identifiers": [ | |
"^com.googlecode.iterm", | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "v", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "v", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "a", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "a", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_unless", | |
"bundle_identifiers": [ | |
"^com.googlecode.iterm", | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "s", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "s", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "t", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "t", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.cocoatech.PathFinder-setapp", | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome", | |
"^com.googlecode.iterm" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "l", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "l", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "n", | |
"modifiers": { | |
"mandatory": [ | |
"left_shift", | |
"left_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "n", | |
"modifiers": [ | |
"left_shift", | |
"left_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "g", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "g", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "u", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "u", | |
"modifiers": [ | |
"left_option", | |
"left_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "h", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "y", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "y", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "y", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "w", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "w", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "slash", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "slash", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.install4j.[-0-9]+.[-0-9]+$", | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "r", | |
"modifiers": { | |
"mandatory": [ | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "r", | |
"modifiers": [ | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.edgemac", | |
"^com.google.Chrome" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "period", | |
"modifiers": { | |
"mandatory": [ | |
"control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "period", | |
"modifiers": [ | |
"command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "p", | |
"modifiers": { | |
"mandatory": [ | |
"left_shift", | |
"left_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "p", | |
"modifiers": [ | |
"left_shift", | |
"left_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "y", | |
"modifiers": { | |
"mandatory": [ | |
"right_shift", | |
"right_control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "y", | |
"modifiers": [ | |
"right_shift", | |
"right_command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "k", | |
"modifiers": { | |
"mandatory": [ | |
"control" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "k", | |
"modifiers": [ | |
"command" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.tinyspeck.slackmacgap" | |
] | |
} | |
] | |
}, | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "p", | |
"modifiers": { | |
"mandatory": [ | |
"left_ctrl", | |
"left_shift" | |
], | |
"optional": [ | |
"any" | |
] | |
} | |
}, | |
"to": [ | |
{ | |
"key_code": "p", | |
"modifiers": [ | |
"left_command", | |
"left_shift" | |
] | |
} | |
], | |
"conditions": [ | |
{ | |
"type": "frontmost_application_if", | |
"bundle_identifiers": [ | |
"^com.microsoft.VSCode" | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
Top comments (0)