Quicksilver Trick: Strip Clipboard Formatting

It’s been a while since I did a Quicksilver one-off, but with all the recent crazy hype for QS beginning once again, it seems like a good time. Plus, this literally just happened.

Do you know what my biggest pet peeve in OS X has been? It’s that it’s too smart for it’s own good.

Let me be more specific: when you copy something to the clipboard, it almost always holds the rich text formatting of the app you copied it from. If you paste it into another rich text app, you end up with something that looks like this:

This, undeniably, sucks. Yes, there are a few times where you want the format to copy, but this is rarely the case with most apps. I’d say maybe 5% of the time this is useful, and 95% of the time it makes me want to snap my MacBook Pro in half.

My solution to date has always been “copy from source app, paste into TextMate, copy back out of TextMate, paste into target”. I love TextMate, but this is needless abuse of a lovely app.

Was talking to Mikey (he of Think) this morning, and he explained the issue thusly:

>”It’s a side effect of copying rich text to the pasteboard server. The app copying it doesn’t know you’re going to take it to another app, and the other app doesn’t know where it came from – just that it’s on the pb.”

And then he threw out his solution to the problem:

$ pbpaste | pbcopy

And I thought, “well, I could alias that I guess, but then I’ve gotta keep jumping into terminal and typing. And I really want a hotkey for this. You know, like a QS trig…”

Oh. Right.

So, friends, if you too are affected by the horribly crippling brilliance of OS X’s rich text pasteboard, simply make the trigger shown at right. If you don’t know how to do this:

  1. Invoke QS.
  2. Type Command-‘ (that’s a single quote) to go to the Trigger preferences.
  3. Create a new trigger by clicking the + button.
  4. When the trigger pane drops down, press the period key to enter text mode.
  5. Type “pbpaste | pbcopy” into the text field. (Or, for the slightly meta, you can copy and paste it from this post.)
  6. Press tab – select “Run Command in Shell” as the action if it’s not already selected.
  7. Save the trigger and then assign a hotkey as normal.

I bound mine to Shift-Option-Command-V, since I’ll tend to hit it right before I paste something out. You can choose whatever you find most comfortable. In case it’s not clear, this takes the contents of your clipboard and pastes them right back into the clipboard. Because this is being run as a shell command, the formatting falls right off.

If you’re entirely unfamiliar with triggers, you might be in need of a read of my trigger tutorial.

Thanks again to Mikey for his help in turning the lightbulb on over my head.

FIRST EDIT: I’ve been reminded (thanks, Suw!) that you need to have the Terminal Plugin installed to have access to the Run Command In Shell action. Also, note that this trigger does not paste for you; it merely strips off formatting while still in the clipboard.

  • http://matrixPointer.com/karl karl

    Or… you could just use Opt+Shift+Cmd+V to “Paste and Match Style” aka without the original styling.

  • http://alanhogan.com/ Alan Hogan

    I do command-space, command-v, command-a, command-x, command-space, command-v to perform this. What’s that do? Open spotlight, paste, select all, cut, close spotlight, paste. It works great because the focus returns to exactly where it was before you opened spotlight.

  • http://alanhogan.com/ Alan Hogan

    I do command-space, command-v, command-a, command-x, command-space, command-v to perform this.



    What’s that do? Open spotlight, paste, select all, cut, close spotlight, paste. It works great because the focus returns to exactly where it was before you opened spotlight.