Wednesday, February 17, 2016

accessing clipboard data from osx terminal

I like Quora, and am impressed by the list of questions and answers they send to my inbox on a semi-daily basis-- their algorithms seem really well-tuned. One of the answers to the Windows-centric  What are some cool hacking tricks using cmd.exe? mentioned you could send the results of ipconfig directly to the clipboard:
ipconfig | clip

I figured there must be some equivalents for OSX, and lo and behold, OSX Daily has an article on it, the short of it is you can do stuff like
pbpaste > clipboard.txt
or then
cat clipboard.txt | pbcopy

I can think of a few uses for this, like using ls instead of cat for a long directory listing (like maybe if I then want to write some macros in my editor to manipulate file names etc) - nothing earthshaking, or that couldn't be done with temp files etc, but still, a nice tool know about.

No comments:

Post a Comment