Being the thoughts and writings of one Gustaf Erikson; father, homeowner, technologist.

This category contains posts about computing, programming, and development

Tuesday, 2005-08-16


Why am I still on Windows?*

Aristotle writes:

Hooking Markdown into the browser, and in fact into any application that has text input widgets at all, is actually more simple than might at first appear: you just need xclip (or some equivalent, I suppose, if you.re not on X11). This little tool can dump any of the X11 selections, such as the clipboard, to its stdout or slurp its stdin into one of the selections.

Thus, I have this shell oneliner bound to a keyboard shortcut in my window manager:

xclip -o -sel clip | Markdown | SmartyPants -2 | xclip -sel clip

With that in place, I simply write my entries in a natural format, then I copy, hit a key, and paste, and there they are, turned to HTML and typographically smartened. Presto.

Anyone know of a Windows analogue of xclip?

* Well, at work I support the damn OS, and at home I just enjoy the eye-candy…

Update: Jim pointed me to UnxUtils and the programs pclip.exe and gclip.exe. Here’s Jim’s post on how to use these with PyTextile, and here’s my version for Markdown + SmartyPants

c:\cygwin\usr\local\bin\pclip.exe | \
c:\cygwin\bin\perl.exe c:\cygwin\usr\local\bin\Markdown.pl | \
c:\cygwin\bin\perl.exe c:\cygwin\usr\local\bin\SmartyPants.pl | \
c:\cygwin\usr\local\bin\gclip.exe

The gnarly code is due to my choice of paths in Windows.

The code works, sorta, but it doesn’t return DOS line endings (\r\n). I guess you could hack Markdown to do this.

Submit a comment

Please enter comments as plain text only; no HTML tags are allowed. Email or URL are optional.

Comments are closed for this story.