Typing Sanskrit diacritics using OSX press-and-hold

(This is an Apple-only post, because it’s all I know, but if someone wants to write down the process for Windows and post it in the comments, please do).

There are a few decent methods for entering Sanskrit (and other languages’) diacritical marks (accents, vowel marks, alternate characters, etc), but if you use them daily, you want your method to be as quick and easy as typing itself. All the alternate characters you could want (mostly!) can be found in a dropdown in your menu bar on the upper right. That dropdown says “Show Emoji & Symbols” and is up here:

It opens a window that has all the alternate characters in it, and you can double-click any of them to add it to text. (That’s the cumbersome way to add diacritics, btw.)

So doing that is easy, but totally slows down typing, and if you use them constantly as I do, the best method I’ve found (on Mac) for adding diacritics is to hack the OSX function known as “press-and-hold.” This is the function that gives you a string of alternate characters to choose from if you hold down a key for about a second. Trouble is, the standard strings of alternate characters don’t include the right ones for Sanskrit.

So here’s instructions for modifying the file that governs which characters are in those strings. (I don’t have the programming skill to invent this—I’m using instructions from here and here.) When I first did it some years ago it was easier, because the information was in a preference file that you could just directly modify, but since OSX Sierra, you can’t directly access the file without disabling what’s called “System Integrity Protection,” (SIP) which is also called “Rootless,” which is probably unintentional poetry. This makes the maneuver more dangerous, because SIP does important protective things. Be sure to turn it back on once your mischief is managed.

1. Open the Marauder’s Map (turn off System Identity Protection)

Update for OSX 10.15 Catalina (10.29.19)

The new operating system changes file permissions in a big way, basically to make the OS more secure. Apple has made the System files all “Read Only” (even if you’re logged in as a Root User). Basically that’s fine for most of us. But that means that it’s even harder to modify things like the preference files in the way this post describes. To get around the new protections (and again, do this at your own risk), use these instructions I found here:

Shut down the computer.
Boot to recovery (⌘-R at boot, hold these keys before the Apple logo).

Open Terminal (in /Applications/Utilities/), type
csrutil disable
and hit return.

Then reboot to the OS, open Terminal again and type:
sudo mount -uw /
hit return, and then
killall Finder
and hit return. [This is the new piece that breaks into Catalina’s locked file system.]

2. Open & modify the press-and-hold file

Open a Finder window. Navigate to: /System/Library/Input Methods/PressAndHold.app/Contents/PlugIns/PAH_Extension.appex/Contents/Resources/ in the Finder.

To go to it quickly, press ⇧⌘G and paste that whole string in.

Note 1: Remember that there are two different Library folders. You want the one nested inside “System” not the one just nested inside Macintosh HD (or whatever your hard drive is named).

Note 2: As you go through that stack of files, you’ll find that when you get to PressAndHold.app, you can’t go further. 2-finger click on the file name (it’s really a “package”) and click “show package contents.” Do the same thing when you get to PAH_Extension.appex.

When you get to the list of Keyboard preference files (they all start with “Keyboard”, then have a language marker like “-en” and end in “.plist”), find the one you use. If you don’t know which one you’re using, look in System Preferences > Keyboard > Input Sources.

Backup the .plist file you’re going to modify by copying it and saving it somewhere with a useful name (like “Keyboard-en-ORIGINAL.plist”) so you can put it back if you err.

Open the file using a code editor. I use Atom, which you can download for free here. Once it’s open, you’ll see a set of code blocks that look like this:

<dict>
	<key>Roman-Accent-A</key>
	<dict>
		<key>Direction</key>
		<string>right</string>
		<key>Keycaps</key>
		<string>A À Á Â Ä Æ Ã Å Ā</string>
		<key>Strings</key>
		<string>A À Á Â Ä Æ Ã Å Ā</string>
	</dict>

That’s the code for holding down a capital A before I modified it. The plain “A” is first in the string, then all the alternates, in the order they appear. For Sanskrit, I want my most commonly used alternates to appear in this list, and I also want them to be first in the list because I just like that (this is optional). So I modified the code to this, putting the long-vowel version (“Ā”) first:

<dict>
	<key>Roman-Accent-A</key>
	<dict>
		<key>Direction</key>
		<string>right</string>
		<key>Keycaps</key>
		<string>A Ā À Á Â Ä Æ Ã Å</string>
		<key>Strings</key>
		<string>A Ā À Á Â Ä Æ Ã Å</string>
	</dict>

Be sure to put the alternate characters in both “Keycaps” and “Strings” strings. Use the “Show Emoji & Symbols” dropdown to find all the characters you need. Then go down through the file, adding any alternate characters you want. (If you want to just download a .plist file with the full set of Sanskrit mods I use, here it is. You would then just open it in Atom and copy the entire contents over the contents of the .plist file in Atom.) Save the file with the original name (“keyboard-en.plist”) and say yes when it asks you if you want to replace the original.

3. Turn SIP/Rootless back on & restart

Test that it works, and once it does, turn Rootless back on using these instructions, as above. Shorthand:

Shut down the computer.
Boot your Mac in Recovery Mode (Command-R while starting up),
open the Terminal application from the menu,
type csrutil enable,
then reboot normally.

That’s it! I hope it works for you and helps your flow as it does mine.


Note after figuring out the Catalina update: (10.29.19) it looks like this process will need to be done anew every time you do a system update, which is annoying. But it’s still my favorite method for typing diacritics, so I’m surrendered to doing it. It was a pain figuring out the new hack, but hopefully now it’s set for a while. If you have a better system, lmk!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

Connect with the beauty and power of Buddhist training.

Receive articles, guided meditations, and tools for starting or deepening your practice, along with Dr. Oakes’ teaching schedule.

We use cookies as part of website function, and ask your consent for this.
OK