Pasting Services

IRC regulars will know that you don’t paste code directly to the channel, but instead use a pasting service and post a link to where this service stores the paste.

TextMate of course has support for this, but recently this support reached new heights.

History

The initial version of the command was mostly proof-of-concept. It stored the paste using http://paste.textmate.org and then sent the URL to a channel named #textmate in Colloquy using AppleScript.

Then came along Brian Donovan and rewrote it to use the much better RAFB pasting service. He also made it ask the user which IRC channel the link should be sent to, making it far more useful for pastes not intended to go to #textmate.

This command has worked very well for quite some time, but recently three unrelated events happened:

  1. Brad Choate created a set of commands to export the current document as HTML and convert the TextMate theme into equivalent CSS. This gives HTML which renders the code almost exactly as shown in TextMate.

  2. Jacob Rus wanted to expand the targets for the pasting command from Colloquy to things like Adium, iChat, the clipboard, etc. and started to work on this.

  3. Josh Goebel created a new pasting service called Pastie for various reasons.

Since Brad had already committed his commands to the TextMate bundle, Jacob had sent me the code he had already written for multiple destinations, and Josh was willing to work with me getting Pastie to accept an HTML variant for display purposes, the only thing left for me was to combine the three things, and so I did.

So the advantages of these combined efforts are:

  • More destinations for the URL:
    • Adium
    • Clipboard
    • Colloquy
    • iChat
    • Quicksilver
    • Web Browser
  • Syntax highlight as powerful as that found in TextMate with selectable theme.
  • Much nicer pasting service: Cleaner look and supports UTF-8.

Instructions

The only thing you need to do is select the text you want to paste and then press ⌃⌥⇧V. This will give you a list of potential targets for the resulting URL.

Paste Bin Menu

If you can’t remember the key equivalent then the command is located in the TextMate bundle reachable by either clicking the gear in the status bar or the Bundles item in the menu bar.

Bundles Menu

When you have located the TextMate bundle you will find an action named Paste Selection / Line to Paste Bin roughly in the middle of the menu.

Textmate Bundle Menu

Another way to reach this item is by using the Select Bundle Item… (⌃⌘T) from the Bundles menu and enter paste or similar, to narrow the list.

Select Bundle Item

9 Comments

  1. 19 Jun 2006 | # Josh Goebel wrote…

    Thanks for the mention Allan. It was fun working with you to pull everything together. And thanks for the few tips needed to add the UTF-8 support to Pastie.

    I hope you're enjoying it. :-)

  2. 19 Jun 2006 | # Jacob Rus wrote…

    Hey Josh,

    Can we make the 'Mac Classic' theme the default in Pastie? It's not what I use in TextMate, but it's the cleanest for a webpage to use.

  3. 19 Jun 2006 | # Jacob Rus wrote…

    Oh, also, the 'download as file' link always returns a '*.rb' file, even when it's supposed to be plain text or python or latex or whatever.

  4. 19 Jun 2006 | # [maven] wrote…

    In the "Select Bundle Item Screen", why isn't the "te" in "paste" highlighted? It seems the much more sensible match to me.

  5. 19 Jun 2006 | # Andreas Wahlin wrote…

    Just curious, it doesen't seem to automaticly create a pastie from my selected text. Instead I have to go to the URL and then paste in my text and save it, wasn't this supposed to be automatically done?

  6. 19 Jun 2006 | # Allan Odgaard wrote…

    [maven]: It’s primarily an abbreviation matcher, so it will favor letters at the beginning of words over consecutive matches.

    Andreas: Yes, it should be automatic. So what exactly happens when you paste?

  7. 19 Jun 2006 | # chandler wrote…

    when i run the script it's having a hard time finding progress.rb i had to go in and add the full path /Applications/TextMate.app/Contents/SharedSupport/Support/lib/progress.rb should this be added to the include path automatically?

  8. 19 Jun 2006 | # Allan Odgaard wrote…

    chandler: it should setup RUBYLIB correctly in bash_init.sh

    You wouldn’t happen to have an outdated local Support folder (from a svn checkout)?

    This would be in /Library/Application Support/TextMate or similar for ~/Library.

  9. 19 Jun 2006 | # chandler wrote…

    ahh yes, that did the trick. thanks!

Comments closed, you can use the mailing list for discussion.