闲云孤鹤

人生在世五十年,大千世界一瞬间,浮生若梦,仿佛间,幻境一场,生者无常,终须尽。...

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

本文转载至:https://langui.sh/2010/11/14/pbpaste-pbcopy-in-mac-os-x-or-terminal-clipboard-fun/

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!


阅读更多
个人分类: MacOSX
相关热词: pbpaste
上一篇[小技巧] trac 如何设置 Search 的最小长度
下一篇[小技巧] mac os x 的 terminal 如何回退一个 word
想对作者说点什么? 我来说一句

Mac OS X Terminal Basics v2.1.2

2011年08月19日 134KB 下载

没有更多推荐了,返回首页

关闭
关闭