To put a file in my paste buffer, I sometimes use Mac’s pbcopy utility:
cat <file> | pbcopy
There’s a better way: the input redirection operator!
If my command could talk, it would say: “Concatenate the file, then send the
output of that concatenation to the pbcopy program.” In the end, it works.
Here’s the better command:
pbcopy < <file>
This uses the input redirection operator, <, to send the file into pbcopy.
No concatenation, no pipe, just the file straight to the program.
Some might call my first example a Useless Use of Cat, because this work does not require us to concatenating anything. If so, I’ll try to do better.
See man zshmisc on Mac for more.