Copy to clipboard without the mouse using xclip

Another quick command line utility thing, this time to copy the contents of a file onto your clipboard without having to use the mouse (this is on Ubuntu, with the bash shell, incidentally).

First install xclip:

sudo apt-get install xclip

Now make an alias for xclip with the flag that directs the clipped contents to the clipboard:

alias xc='xclip -selection clipboard'

(you can also put this line in your ~/.bashrc file)

Then you can put stuff onto your clipboard with this:

cat aFile.txt | xc

and paste with the usual keystrokes (CTRL-Shift-v on Ubuntu).

Leave a Reply

Your email address will not be published.