Post

Replies

Boosts

Views

Activity

Reply to Direct Access to macOS Text Replacements
I would like to simply access a .plist file (or similar) with the existing user defined Text Replacement settings. For context, I'm an extensive user of this feature, and use macOS to add shortcuts for text glyphs and take advantage of the fact that it will synch to my iPhone and iPad. seeing as the iPhoneOS and iPadOS implementations of "Text Replacement" settings don't easily facilitate the use of non-ASCII glyphs, especially non-UTF-8 Gylphs (there's more to advanced glyphs than emojis Apple!). many Application developer on macOS have not provided support for the system level "text replacement" settings to work in their app, notably, all the Adobe CC apps, FireFox and a bunch of text editing applications like Xcode(!?), Sublime, Visual Studio Code, macvim, emacs. Fortuately some of these apps have their own text conversion functionality or plugins. The issue is exporting the 100+ shortcuts I have in my macOS System settings to some kind of JSON or CSV file for importing or pasting into these other apps and plugins. For instance there's a Firefox plugin that can import a JSON file of strings tuples. Unfortunately, Apple engineers have made it impossible to simply select all of the string pairs in Settings> Keyboard > Text Replacement and then use the Copy and Paste commands to etract the text I need. I probably could have manually type these 100+ codes out in the time I've spent on the phone to Apple and researching this issue online without any luck. But I'd like an answer to this conundrum as I'll need to keep exporting the list going forward. If there is some kind of way to access this info and export/import it from macOS I could write a script to automate two-way or multi-node syncing of the text pair tuples between all my apps. (please not via AppleScript, its such a confusing language for occasional users) . I even considered processing a few screenshots of the text replacement fields using Adobe Acrobat text recognition software, but many of the gylphs I use are mathematical and combination diacritics symbols (UTF-16) etc and I don't think Acrobat will do to well on it. Thank-you.
Oct ’24
Reply to Text Replacement preferences are not exportabe, is there a PLIST file or similar that stores these values?
Solution In summary the relevant filepath is: ~/Library/KeyboardServices/TextReplacements.db Extracting the data to extract using sqlite3 (should be on macOS by default): sqlite3 ~/Library/KeyboardServices/TextReplacements.db Run the following commands to output the ZSHORTCUT and ZPHRASE to a CSV file: .headers on .mode csv .output text_replacements.csv SELECT ZSHORTCUT, ZPHRASE FROM ZTEXTREPLACEMENTENTRY; .exit Converting CSV to JSON If you want to convert the CSV to JSON, you can either use a tool like jq or convert it with a Python one-liner (see attached text file). python3 -c " import csv, json with open('text_replacements.csv') as f: reader = csv.DictReader(f) print(json.dumps(list(reader), indent=4)) " > text_replacements.json Use the correct field names in my case I opened in a text editor and replaced all "ZSHORTCUT" with "repalce" and all "ZPHRASE" with "with" then imported the JSON file into the Firefox plugin called TextFast . all working now.. ChatGTP solved this for me conversation_text.txt LINK to ChatGTP instructions: https://chatgpt.com/share/6708a59e-7ccc-8006-b095-d6da9545f587 in case that link doesn't work in future i attached as text file.
Oct ’24