# Unicode keyboard substitutions globally in MacOS

**URL:** <https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713>\
**Category:** Tooling\
**Created:** [April 16, 2020, 8:38pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713 "2020-04-16T20:38:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximerischard](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@maximerischard](https://discourse.julialang.org/u/maximerischard)\
**Post date:** [April 16, 2020, 8:38pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/1 "2020-04-16T20:38:59Z")

</div>

If like me you love the tab-completions in the julia REPL and in jupyter notebooks, and want to be able to use them everywhere in MacOS (for example while writing an email), you may find this useful. I generated [this plist file](https://gist.github.com/maximerischard/e76b968e63b1b98f613b6a89d4b26d95) which you can download and then drag into `System Preferences > Keyboard > Text` (straight into the substitutions box on the left). Now you should be able to use the [unicode substitutions in most applications](https://appletoolbox.com/text-replacement-in-macos-how-to-use-it-and-fix-if-its-not-working/).

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 16, 2020, 9:41pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/2 "2020-04-16T21:41:57Z")

</div>

Wow, this is brilliant. Works like a charm!

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [April 16, 2020, 10:13pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/3 "2020-04-16T22:13:32Z")

</div>

This is almost great but for some reason \alpha and \beta complete to A and B, whereas \gamma and \delta work. They look fine in the Keyboard - Text box.

---

<div class="post-metadata">

**Author:** ![maximerischard](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@maximerischard](https://discourse.julialang.org/u/maximerischard)\
**Post date:** [April 16, 2020, 11:24pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/4 "2020-04-16T23:24:05Z")

</div>

Yes, same here, that’s very odd. With just the following plist:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>phrase</key>
        <string>α</string>
        <key>shortcut</key>
        <string>\alpha</string>
    </dict>
    <dict>
        <key>phrase</key>
        <string>Α</string>
        <key>shortcut</key>
        <string>\Alpha</string>
    </dict>
</array>
</plist>

```

it works absolutely fine…

Here’s the julia code to generate the entire plist:

```julia
header = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>"""
footer = """</array>
</plist>"""

import REPL
symbols = union(REPL.REPLCompletions.latex_symbols,
                      REPL.REPLCompletions.emoji_symbols)
println(header)
for (command, character) in symbols
    item = """
        <dict>
            <key>phrase</key>
            <string>$character</string>
            <key>shortcut</key>
            <string>$command</string>
        </dict>
    """
	print(item)
end
println(footer)

```

---

<div class="post-metadata">

**Author:** ![maximerischard](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@maximerischard](https://discourse.julialang.org/u/maximerischard)\
**Post date:** [April 18, 2020, 9:35am UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/5 "2020-04-18T09:35:10Z")

</div>

Right! It turns out MacOS does some automatic capitalisation of substitutions, and so it was getting confused by `\alpha` and `\Alpha` both being defined (I still don’t fully understand what’s happening under the hood). The good news is that by simply deleting the `\Alpha` substitution (and all other capital letters), it now works perfectly, as MacOS automatically capitalises the alpha. So I’ve updated the plist in the above link. And here’s the updated julia code to generate the plist:

```julia
header = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>"""
footer = """</array>
</plist>"""

import REPL
symbols = union(REPL.REPLCompletions.latex_symbols,
                      REPL.REPLCompletions.emoji_symbols)
symbolset = Set(kv[1] for kv in symbols)
println(header)
for (command, character) in symbols
	if (lowercase(command) != command) & (lowercase(command) ∈ symbolset)
		continue
	end
    item = """
        <dict>
            <key>phrase</key>
            <string>$character</string>
            <key>shortcut</key>
            <string>$command</string>
        </dict>
    """
	print(item)
end
println(footer)

```

Edit: And if you find that some of the subscript shortcuts like `\_i → ᵢ` don’t work, then try deleting all the emojis from the substitutions table. My hypothesis is that there’s an undocumented limit on the number of substitutions (perhaps 2048?) and substitutions that are low in the alphabetical order (high in the table) get silently dropped after it is exceeded.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [April 18, 2020, 4:08pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/6 "2020-04-18T16:08:25Z")

</div>

Unfortunately, the drag-n-drop part doesn’t work for me. I’m dragging the plist file into the substitutions box and the arrow also gets a little green plus sign but when I drop it nothing happens. I’m on Catalina 10.15.4

Update: The short plist with just \alpha and \Alpha from above works fine but the one in the gist does not. ☹

---

<div class="post-metadata">

**Author:** ![trappmartin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trappmartin/32/1165_2.png) [@trappmartin](https://discourse.julialang.org/u/trappmartin)\
**Post date:** [April 19, 2020, 1:19pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/7 "2020-04-19T13:19:47Z")

</div>

The following works fine for me: [https://raw.githubusercontent.com/tslmy/latex-input-iOS-macOS/master/LaTeX.plist](https://raw.githubusercontent.com/tslmy/latex-input-iOS-macOS/master/LaTeX.plist)

---

<div class="post-metadata">

**Author:** ![EHBaozi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehbaozi/32/14854_2.png) [@EHBaozi](https://discourse.julialang.org/u/EHBaozi)\
**Post date:** [April 19, 2020, 5:58pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/8 "2020-04-19T17:58:40Z")

</div>

Made an AutoHotkey script for Windows users: [Unicode latex substitutions from julia for AutoHotkey · GitHub](https://gist.github.com/EHBaozi/cdf18e881798447c3d9b784824f89103)

The file needs to be resaved with UTF-8 BOM encoding, otherwise it spits out weird stuff. Also substitution needs to be completed with a Tab.

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [November 7, 2021, 7:02pm UTC](https://discourse.julialang.org/t/unicode-keyboard-substitutions-globally-in-macos/37713/9 "2021-11-07T19:02:49Z")

</div>

I’m having the same issue, and I’m on Mac Os Big Sur 11.6.
