The “Paste Line/Selection Online” (a.k.a. ”Pastie”) command in TextMate is great. You can send code straight from the buffer to a paste service with a keyboard shortcut (
The command opens a very full-featured dialog:
You can have the pastie URL sent to Colloquy (IRC) or Adium (IM). I never use this. I just want it to go into my clipboard. From there, I can paste it into an IRC or IM message. Selecting the right conversation in the dialog is more work, and only the URL is sent: you have to set things up before or quickly explain yourself.
Furthermore, sometimes pasting will take several seconds. I’ve found myself pasting and undoing repeatedly until the URL appears. TextMate will flash a tooltip when pasting is done, but that doesn’t help you if you’re in another app by then.
Oh, and the only thing I really want to choose is the privacy level: if the paste should be public for everyone to see, or private. In the standard dialog, the privacy setting is a checkbox that requires using the mouse or tabbing extensively.
I made a new front-end for the command that does what I want and nothing more:
You just press
↩ to paste it as private, hit the space bar to paste it as public, or
⎋ to cancel. The URL is copied to clipboard.
The rationale for having “Private” be the default button is that it’s the less “dangerous” action – it’s no big deal to make code private that was really meant to be public, but it would suck to get it wrong the other way around. Also, most of the time, I don’t care to have pastes available to people I didn’t give the URL to.
Oh, and the command Growls when done:
Get it here. Note that it replaces the default Pastie command (same guid).
There is no option for soft-wrapping. I never used that checkbox. The default smarts is to soft-wrap text and not wrap code (based on the grammar scope). Works for me.
You can easily configure the script to not Growl or copy to clipboard, and to do open the URL in the default browser or whatever else you prefer that the old dialog did.
Update 2007-07-11I realized I’d prefer it to pastie document or selection, not line or selection. If you agree, get this version of the command instead. So if no text is selected, it will pastie the entire document contents instead of the current line. I also updated both the old and the new versions of the command to ensure they finish copying to clipboard before growling; before this update, it would actually growl just before copying.
Update 2007-09-21Both versions of the command have been updated to use the URL
http://pastie.textmate.org/pastesinstead of the deprecated
Update 2007-10-27Both versions of the command have been updated since the way to get the user’s name has changed. By default, your name will go to Pastie as “Real Name (username)”. If you want to use something else, set the
TM_AUTHORenvironment variable. Another minor change is that the command now uses
/usr/local/bin/growlnotifyif it can’t be found elsewhere in your PATH. This means no painful search path configuration if you stick it where it wants to go.