ymendel / dotfiles

23 stars 2 forks source link

Making keyboard shortcuts show up in System Preferences #1

Open ZevEisenberg opened 9 years ago

ZevEisenberg commented 9 years ago

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"
}
ymendel commented 9 years ago

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.

ZevEisenberg commented 9 years ago

:D

lucaorio commented 7 years ago

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

ZevEisenberg commented 7 years ago

@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.