Copy output from terminal directly to your clipboard! (Linux)

PROBLEM:Β It is difficult to copy and past outputs from and to terminal
SOLUTION: Use xclip!

Install xclip

To install xclip on Ubuntu just use apt get, on other use the equivalent command.

apt install xclip

Basic commands

To copy output to your clipboard, just simply use | xclip (| means, everything before pipe is input for command after pipe)like this:

cat myfile | xclip

And you have content of myfile in your clipboard!
To paste from your clipboard, just use:

xclip -o

Advanced strategy!

To work better with xclip, you can use aliases to work faster πŸ™‚

alias c="xclip"
alias v="xclip -o"

In use case:

#Copy content of myfile
cat myfile | c
#Paste content of myfile
v

Leave a Reply

Your email address will not be published. Required fields are marked *