Today I Learned: 19/11/2023 - Piping to the clipboard on a linux system
Publish date: 19 Nov 2023
I occasionally output text from command line tools on my Ubuntu linux machine entirely to put them into the system clipboard to paste into some other tooling. I recently found this can be done via a pipe to the xclip command, which was already installed on my system. As an example:
echo "war_and_peace_in_the_original_klingon.txt | translator | xclip -selection clipboard
The -selection clipboard portion uses the system clipboard, instead of an X buffer which xclip defaults to.