Firstly make sure that you have the required software installed – xclip
for Linux or pbcopy
for MacOS/OSX.
For Linux
For Debian-based systems execute the following:
|
|
For Redhat-based systems run:
|
|
For systems with pacman e.g. Arch and Manjaro:
|
|
Gentoo-based systems:
|
|
If you have any trouble installing xclip
due to permission levels, prefix the above commands with sudo
to escalate yourself momentarily to administrator level.
Now for the actual copy and pasting!
To copy text or the output of a command to the clipboard you need to pipe it to clip -selection clipboard
. The following two examples copy the contents of readme.txt
and output of ls
to the clipboard, respectively.
|
|
|
|
And now for pasting from the clipboard. To paste from the clipboard you need to execute:
|
|
For MacOS/OSX
pbcopy
and pbpaste
should come installed on your system, so no installation there :)
In order to send some output to the clipboard, simply pipe it to pbcopy
, thusly:
|
|
And in order to paste the contents from the clipboard run:
|
|
The best use of this command would be to redirect the output into a file or assign this command to a keyboard shortcut.
:)