View Full Version : Piping text to Clipboard?
March 21st, 2008, 09:32 PM
I find my self spending quite a bit of time in the terminal, and the work I do has me constantly taking some bits of information from the terminal and pasting them into other applications. I'm looking for a nice way to get text from the terminal to the clipboard. Something like:
"pwd > Clipboard"
I know that's never going to work but what I'm asking is if there's a semi nice way to do this, maybe piping the text to an apple script that will then place that text into the clipboard?
Does this even make sense to anyone?
March 22nd, 2008, 03:27 PM
Hmm. I tried rigging up an AppleScript using the osascript command, but as far as I can tell osascript will never accept script arguments from stdin. Bummer. You can do it with angle-quotes, but only if the output has no spaces or other non-shell-friendly characters.
Looks like macosxhints has the answer, though. http://www.macosxhints.com/article.php?story=2003050204544799
It's as simple as:
pwd | pbcopy
Nice! This is one of those questions I wouldn't have thought to ask myself, but I'm glad to have the answer now. :)
March 22nd, 2008, 03:31 PM
Yes, it does. There seems to be a service called pboard. Also, there are two commands,
pbcopy and pbpaste that use the service.
$ pwd | pbpaste
does what you asked.
(All this I got by typing "man -k paste", which gave pboard, and then "man -k pboard")
March 22nd, 2008, 03:35 PM
Ooops! Mikuro already answered when I was typing my answer. Also, I should have used
pbcopy instead of pbpaste.
March 22nd, 2008, 05:05 PM
OOhhhh fantastic. I was really hoping something like that existed, GO APPLE. I spend alot of time looking for something like this on os x hints but I guess I was searching for the wrong things. Thanks guys