# Piping text to Clipboard?



## blackoutspy (Mar 21, 2008)

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?


----------



## Mikuro (Mar 22, 2008)

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.


----------



## artov (Mar 22, 2008)

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")


----------



## artov (Mar 22, 2008)

Ooops! Mikuro already answered when I was typing my answer. Also, I should have used
pbcopy instead of pbpaste.


----------



## blackoutspy (Mar 22, 2008)

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


----------

