Automatic Emoji Expansion in macOS
My preferred way of typing emoji is using the
:emoji_name: shortcode syntax. This is great if I’m using Slack or GitHub, but doesn’t translate as well to other applications.
There are apps like Rocket that bring shortcodes to all inputs and more general text expansion apps like Espanso that have support for emoji shortcodes, but I didn’t really want to install an app to do this. After all, text expansion is built in to macOS.
There are a lot of emoji and manually entering all of them via System Preferences was definitely too tedious to be feasible, so I started to look for a programmatic solution. GitHub maintains a library called gemoji with information about every emoji and its shortcodes, which would be how I could enumerate all the snippets to add and what emoji they’d map to.
On the macOS side, I came across a couple different StackExchange posts about how I could set these snippets programmatically. I found working with
.GlobalPreferences.plist to be unreliable, the options would be unset a few minutes after I set them. But what did work was to drag a plist file with my snippets into System Preferences itself.
And boom, emoji everywhere!
Note: Apple syncs your snippets between your devices. Importing these snippets on your computer will make them available on your iPhone and/or iPad as well!