A tip for using Plain Clip with TextExpander

One of my favorite utilities, TextExpander, was recently updated to allow the execution of shell scripts based on the typed triggers. This makes a very powerful tool even more useful.

Coincidentally, Macworld has published a nice overview of another of my most-used tools, Plain Clip. It's a small, faceless application that strips formatting from text on the clipboard. It's essential for copy-and-paste between applications when you don't want to also copy font, color, and other text attributes. The new version of Plain Clip adds some handy features for stripping invisible characters and extra spaces.

The Macworld article is great, but it doesn't take into account the latest TextExpander update. (No doubt it was written before this new version was released.) So, when I followed its advice on how to tie TextExpander to Plain Clip, the two don't play along with each other exactly as I expected. (If you follow the steps to execute Plain Clip via an AppleScript, as the article describes, it will probably work fine.)

But if you want to use the more direct shell script method, you must omit the -v option that's described in the article. This is because TextExpander wants to automatically replace your snippet with the result of the script. With the -v option, Plain Clip returns nothing and fakes a paste command, so your typed trigger is not correctly replaced. To resolve this, drop the -v and add a line to the shell script that echoes the cleaned-up clipboard.

TextExpander.jpg

This causes TextExpander to replace your trigger with the output from Plain Clip, which is exactly what you want. As Macworld says, it's a very handy thing indeed.

For more, see My Favorite TextExpander Tip.