24th September, 2004

Using Ruby one-liners with Quicksilver

Filed under: Technology, — bsag @ 03:09 PM

Sometimes a Unix-based system can be a beautiful thing. Take a little problem and solution I came across today. I had been writing some notes on a paper I was reading in the Vim Outliner, and wanted to paste a paragraph or two into the notes section of Endnote (a reference manager). But there was immediately an irksome problem: Endnote doesn’t understand Unix line endings, and my notes were also hard-wrapped to 72 characters, with a ‘pipe’ character (|) and tab before each line of text. Worse still, Endnote doesn’t have a find and replace command1. I could have opened up BBEdit or something similar and constructed the appropriate find and replace there, but that seemed annoyingly long-winded. Then I remembered that you can access the contents of the system clipboard directly using the commands pbpaste and pbcopy. Because they work like standard Unix commands, you can pipe other commands to them, and so build up a useful tool from a chain of smaller commands. This example shows you how to filter the text on the clipboard through a command to munge it in some way, and then put it back on the clipboard ready for pasting—no intermediate files required!

{Read more...}

Page 1 of 1 pages

Powered by ExpressionEngine :: © www.rousette.org.uk, 2002-2008 :: [XHTML] [CSS] [508]