Tuesday, November 10, 2009

Cool Command line utility of the day: clip

The Old New Thing - Little-known command line utility: clip

“Windows Vista includes a tiny command line utility called clip. All it does is paste its stdin onto the clipboard.

dir  clip
echo hey clip

…”

So much that I don’t know…sigh (TG cause otherwise this job would get SO boring ;)

This is a pretty cool Windows Vista/Win7 (and probably post Vista server OS’s too) utility that pipes into the clipboard. If you’ve ever redirected/piped a command line utility into a text file just so you could then easily cut-n-paste from it, then this utility is just for you (been there, done that, got the T-shirt)

So since I’m on a PowerShell kick, I did a quick 5 second search for doing something similar in PS and it’s not quite so easy (kind of, sort of).

Since PS has the power of .Net behind it, you can use .Net’s clipboard goodness to make it happen, Windows PowerShell Blog - Copy console screen to system clipboard. Yet if you look at that code in the post you’ll see it’s not really all the pretty. Not hard, yet not as easy as the clip utility or some kind of more integrated solution.

A much prettier solution is the PowerShell Community Extensions (PSCX) Out-clipboard, shown here, The Endeavour - Manipulating the clipboard with PowerShell

And of course, clip can just be used from PS too… ;)

Related Past Post XRef:
PowerShell Community Extensions V1.1.1 Released

No comments: