A tip for using Plain Clip with TextExpander
February 19, 2009
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.
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.
Thanks for solving this puzzle for me.
Where did you get documentation on the command-line options for /Applications/Plain\ Clip.app/pc? (`/Applications/Plain\ Clip.app/pc -h` and `/Applications/Plain\ Clip.app/pc --help` output nothing and I couldn't find anything on http://www.bluem.net/. )
Posted by: Daryl Spitzer | March 02, 2009 at 10:33 AM
Hi, Daryl, the doc you seek is in the Read Me included with the Plain Clip download. I agree it's a shame that --help doesn't return anything.
Posted by: Gordon Meyer | March 02, 2009 at 10:46 AM
I should have read the Read Me. (That's not the first time I've said that. :-)
This (and Dan Frakes' MacGem) inspired me to create a "Quoted Text Paste" TextExpander snippet: http://yacitus.com/2009/03/textexpander-snippet-to-paste-quoted.html
Posted by: Daryl Spitzer | March 03, 2009 at 11:41 AM
Very nice! Thanks, Daryl.
Posted by: Gordon Meyer | March 03, 2009 at 11:55 AM
Thanks for the tip! I was going crazy to figure how to work this out
Posted by: Alfonso | May 16, 2009 at 03:30 PM
Thanks for the great tip. I followed your instructions and it was working yesterday. Today, when I type ptp, only "p" and "t" appear, and then I get a system error message. The command doesn't complete and I just see "pt" on the screen. Any ideas?
Posted by: Chris Kresser | December 04, 2009 at 07:02 PM