Today I've been overhauling my Xcode setup, including hotkeys. When I attempted to assign ⌘ ⌃ D
to the “Show code review” action, I got a warning that the operating system already uses this combination, hence it wouldn't work. I checked, and indeed it was used to show the definition of the selected word.
I navigated to the System Preferences > Keyboard > Shortcuts
to reassign or disable this shortcut, but there was no such entry. Doh!
I felt like insisting on using this hotkey for the diff view in the Xcode, so I started digging. After some googling, I found a com.apple.symbolichotkeys.plist
property list that holds a subset of system shortcuts.
Since plist
files are binaries, it requires special tooling to inspect them. It can be Xcode or PlistBuddy
cli utility.
The output was puzzling.
Further investigation revealed that the entry of AppleSymbolicHotKeys
dict contains:
key
: an int identifier of an action performed on the provided keybinding.enabled
: a bool flag that enables/disables a shortcut.type
: no idea what it is, but I didn't care.parameters
: an array that encodes a keybinding:
65535
for non-ASCII characters).⌘
, ⌃
, ⇧
and ⌥
):The following gist helps a lot with decoding parameters
array.
I hoped that if I find the entry with the parameters
set to Array {100 2 1310720}
which corresponds to ⌘ ⌃ D
hotkey and flip its enabled
flag, it will do the trick. But nope, such entry didn't exist in this dict. Doh!
Apparently, this hotkey comes from somewhere else, and at this point, I was supposed to give up, but one more idea crossed my mind. What if it is possible to add the corresponding action id to this plist
and disable it? All I need is an identifier of this action. It was the hardest part. I still have no idea where these identifiers come from, but there is only one place on the internet where I found the mapping: a forum post that is long gone but stored in the web archive. Someone posted a source of such plist
with comments on what action corresponds to a specific id.
So after inspecting it very closely, I found something similar:
And it was exactly what I was looking for. Running this command, I disabled the system shortcut.
The last note is that changes to this file don't apply immediately. It would require a restart. But there is a command that applies changes right here right now: