To copy text to the clipboard from the Linux command line in Xorg, we need to install a nice utility called xclip. This will allow us to copy text from the terminal to the clipboard.
Install xclip.
jason@jason-desktop:~$ sudo apt install xclip |
Then create the bash alias we need for this to work.
jason@jason-desktop:~$ alias xclip="xclip -selection c" |
Now copy some sample text to the clipboard.
jason@jason-desktop:~$ echo "Hello Testing." | xclip |
That is how easy this is to do. This way it is easy to redirect output of a command or the contents of a text file to the clipboard. Very useful for those of you that use the terminal a lot.