Friday, October 19, 2012

shell clipboard

Ever wanted to cut something from the shell?
Do you need to paste some information stored in a file into your web browser, but you are too lazy to fire up your text editor, select, and hit ctrl+c?
Are you a shell enthusiast?

Than xclip(1) is good for you. It's a CLI to X clipboard, which lets you store into the clipboard buffer what you type on stdin, or from a file.

But to simplify more the task of cutting and pasting, you can create (if you are using, for example, bash) a simple alias in your .bashrc file like this one:

alias clipboard="xclip -i -selection clipboard"

Then, you can simply copy a file in the clipboard like:

$ cat file | clipboard

or directly write in it:

$ clipboard 
hi, how are you?

And your productivity will be maximized for sure!!!