Saturday, November 10, 2012

pbpaste & pbcopy in Linux

People who are using Mac OS X Terminal may will use these two useful commands: pbcopy & pbpaste, with them you could access your clipboard from the command line.

Recently, I've switched to Linux Mint from Mountain Lion, and I didn't find any alternatives to these two commands, but I found a closet way to implement them: xclip




xclip, you can say it is the clipboard for command line, but the best thing is, it could access the system clipboard in your desktop environment, so I decided to make two command by alias, and make them works just like on Mac OS X.

alias pbcopy="xclip -selection clipboard -i"
alias pbpaste="xclip -selection clipboard -o"

xclip with -i option will receive input from stdin, and store them in your selection(in here, it's clipboard).

xclip with -o option do output the string you just stored in the selection(clipboard).

So, that's it, they works just like under Mac OS X.

No comments:

Post a Comment