Do you spend valueable developer time on mucking around with a mouse to select the lines that you’d like to copy into a clipboard? Do you ever daydream about having an extra 10 seconds in a day? If yes, please continue reading.

Why would you need it?

Say you have a file you’d like copied to a virutal machine. You could use scp yes, but who has the time to write scp -i <location-to-pem> <source-file> <hostname>@<ip>:<target-dir> all the time?

Introducing the command you never realized you needed

Assuming you’re running a Unix system (like most sane developers out there), cat <some-file> | xclip -selection clipboard 1 will copy the contents of a file into your system clipboard. You can then paste it anywhere you’d like it pasted.

For MacOs

cat <some-file> | pbcopy does the same thing

Awesome! I want!! How do I install it?

The usual way anything is done in the Unix world - sudo apt install -y xclip (for Ubuntu/Debian). Replace with the suitable equivalent for your OS.