4

There are a few users here that use the same replacement text between several machines. We'd like to be able to sync up the replacement table between the systems.

Right now the manual way of doing this consists of selecting all items from System Preferences -> Keyboard -> Text entries on the table below this tab and then drag them out to Finder. Here's the table I'm talking about: example

This creates a plist that can then be shared and dragged back onto this table for importation.

I suspect that there's a way to manually capture the plist or a portion of this configuration wherever it exists and then simply set up a sync script that keeps us all in sync every day.

EDIT: For what it's worth, I did a little digging and found that these values are stored in ~/Library/Preferences/.GlobalPreferences.plist. If you look you'll see these stored in the NSUserDictionaryReplacementItems key.

I found that you can pull out these keys with the following command: /usr/libexec/PlistBuddy -c "Print :NSUserDictionaryReplacementItems" ~/Library/Preferences/.GlobalPreferences.plist

So now it's going to be a matter of storing these and reinserting them into another system's plist key.

Any ideas on how to do this manually from the shell so as to be able to automate?

  • 1
    Not really answering the question, but maybe addressing the underlying need: iCloud sync of text replacements should be fixed in iOS 11 and MacOS 10.13 High Sierra. daringfireball.net/linked/2017/09/27/… – ddaa Oct 23 '17 at 10:10
  • Thanks, yes, I should have noted that myself. This is helped (although I would still like to do it). Funny enough it seems to have come as a response from a feature request that I made to Apple. LOL. I'll give you an up vote, although I would still like to leave this around as not yet answered for an actual answer if it exists... – ylluminate Oct 27 '17 at 18:04
5

There is an unofficial command line tool, which does exactly what you want, its called shortcuts. As mentioned on GitHub, you can install it via homebrew

brew install rodionovd/taps/shortcuts

and then list your current replacements via

shortcuts read

and add new ones via

shortcuts import <input.plist>
shortcuts create <shortcut> <new phrase>
shortcuts update <shortcut> <phrase>
shortcuts delete <shortcut>

for details, see the documentation.

-2

If it helps, if all that you have is a non-bootable backup of the old system, simply grabbing the entries from the .GlobalPreferences.plist manually may not work, as the entries are formatted differently there. You may need to do some find and replace so that

        <dict>
        <key>on</key>
        <integer>1</integer>
        <key>replace</key>
        <string>shruggie</string>
        <key>with</key>
        <string>¯\_(ツ)_/¯</string>
    </dict>

becomes

        <dict>
        <key>shortcut</key>
        <string>shruggie</string>
        <key>phrase</key>
        <string>¯\_(ツ)_/¯</string>
    </dict>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .