dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Making keyboard shortcuts show up in System Preferences

Open ZevEisenberg opened this issue 11 years ago • 4 comments

I was googling around and I happened upon your dot files, where you state this on your keyboard shortcut adding commands:

These shortcuts will not show in System Preferences

All you have to do is add an entry to the com.apple.custommenu.apps to the com.apple.universalaccess preference. Don’t add duplicates, or you will make System Preferences crash. I have a function that I use to prevent this:

function addCustomMenuEntryIfNeeded
{
    if [[ $# == 0 || $# > 1 ]]; then
        echo "usage: addCustomMenuEntryIfNeeded com.company.appname"
        return 1
    else
        contents=`defaults read com.apple.universalaccess "com.apple.custommenu.apps"`
        grepResults=`echo $contents | grep $1`
        if [[ -z $grepResults ]]; then
            # does not contain app
            defaults write com.apple.universalaccess "com.apple.custommenu.apps" -array-add "$1"
        else
            # contains app already, so do nothing
        fi
    fi
}

And I use it like this:

function fixTerminal
{
    defaults write com.apple.Terminal NSUserKeyEquivalents '{ "Select Next Tab" = "^\U21e5"; "Select Previous Tab" = "^$\U21e5"; }'
    addCustomMenuEntryIfNeeded "com.apple.Terminal"
}

ZevEisenberg avatar Jan 13 '15 23:01 ZevEisenberg

Wow, thanks a lot, Zev! I'm not sure when I'll get around to actually adding this (the list is long, and my dotfiles don't get a lot of attention), but I definitely appreciate the tip.

Also, I just installed Padiddle. I'll see if I can prioritize making my dotfiles a little better over breaking my iPad.

ymendel avatar Jan 14 '15 08:01 ymendel

:D

ZevEisenberg avatar Jan 14 '15 12:01 ZevEisenberg

Hey @ZevEisenberg , great suggestion! Do you know how to apply this to the NSUserDictionaryReplacementItems?

lucaorio avatar Nov 29 '16 04:11 lucaorio

@lucaorio no, but you can try some of the debugging/exploration techniques I mentioned here: https://www.raizlabs.com/dev/2015/02/how-to-script-os-x-keyboard-shortcuts/

The main one is to use fseventer to see which files have changed. If you can't get a copy (the developer's site is down), let me know and I can send you a copy. It only works on Sierra if you launch it, quit it, and launch it again. I'll be so sad when it breaks for good.

ZevEisenberg avatar Nov 29 '16 17:11 ZevEisenberg