Entering Pinyin tone marks in Mac OS X is a little challenging. There are some ways to do so, most notably using the built-in “ABC Extended” keyboard layout, but the key combinations are not very intuitive. Hence I created my own layout that uses simple CTRL key shortcuts for entering the tones, for example:
To use the Pinyin keyboard layout, first download gb-pinyin-20191204.zip and unzip it. Then copy the keyboard layout to the appropriate location:
cp -R GB-Pinyin.bundle ~/Library/Keyboard\ Layouts
Next, go to System Preferences | Keyboard | Input Sources, click the + sign, scroll to the bottom of the languages list, select Others, then select GB-Pinyin on the right, and finally click the Add button.