Here is a cool little OS X tip that I stumbled upon a couple of weeks ago. I was writing documentation for the setup of one of our applications and I found myself copying the contents of configuration files into the wiki manually. If you have done this before, you know that it can be pretty annoying when you are working from the terminal and you end up cutting off the ends of lines because you don’t realize that they are chopped off in nano.
However, thanks to Stack Overflow, I was able to find a very elegant solution for this situation when you are working from a Mac client: pbcopy (and the yen to it’s yang, pbpaste). These 2 little programs allow you to pipe text to and from your clipboard into your terminal. For example, pretend I have a configuration file that I need to copy into a blog post or wiki:
$ cat localhost.conf | pbcopy
Now I can just use a standard paste command to insert the contents of the file into any input field. No need to open the file in an editor: easy. The inverse is also possible. Pretend you have copied a code snippet from an online tutorial to your clipboard and you need to create a file with the copied text as the content.
$ pbpaste > somefile.txt
I am sure that there are some other cool uses for these commands, so put your ideas into the comments!