if you have X installed you may try xsel in this way :
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
or with xclip :
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
now you can use'em :
echo 'go to my clipboard' | pbcopy
when I don't have X I use GNU Screen functionality to copy between open shells in a session using keyboard
to copy : Ctrl-a -> Esc -> go to wanted position * -> Space (to begin selecting) -> press k to go forward mark text -> Enter
to paste : Ctrl-a + ]
* movements are done with vim like key bindings (j, k, l & m).
A tool that can be helpful with this is ClipIt (and similar clipboard managers). Not only it plays nicely in the terminal, it also preserves the clipboard history. Quite useful.
– brandizzi – 2016-12-10T18:57:09.3872
...and for those that don't know what pbcopy is, here's the man page http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html
– Rob Cowell – 2011-05-25T09:48:13.497