# pbpaste & pbcopy in Mac OS X (or: Terminal + Clipboard = Fun!)

175人阅读 评论(0)

The OS X shell is very powerful, but some wonderfully useful commands are almost entirely unknown to the community at large. Two of these forgotten commands are pbcopy and pbpaste. Let's take a quick look at what they can do.

## pbcopy

This command allows you to copy text from stdin into the clipboard1 buffer. Trivial example:

echo 'Hello World!' | pbcopy


"Hello World!" is now in your clipboard.

## pbpaste

Pastes from your clipboard to stdout. Trivial example:

echo pbpaste


This will echo the contents of your clipboard. If you're following along you'll see "Hello World!".

## What Can I Do With These?

What can't you do! Oh, you want examples? Well...

• You could grab the output of a grep/awk/sed to paste into IM/IRC.

• You could use a macro tool (like iKey, QS, et cetera) to create text modifying workflows that grab highlighted text, manipulate it, and replace it inline.

• You could pull changelogs from svn into the clipboard when tagging for release so you could email them to coworkers.

Let me know what amazing things you come up with to enhance your own productivity!

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：2063429次
• 积分：25919
• 等级：
• 排名：第228名
• 原创：433篇
• 转载：1011篇
• 译文：147篇
• 评论：80条
评论排行
最新评论