0

I would like to create a helper function that displays my public key in the terminal and also copies it to the clipboard. How would I do that?

I tried cat ~/.ssh/id_rsa.pub | pbcopy, but this only copies the key to the clipboard.

1 Answer 1

2

Just paste the clipboard into the terminal window-

cat ~/.ssh/id_rsa.pub | pbcopy; pbpaste

or use tee in the pipe with process substitution

cat ~/.ssh/id_rsa.pub | tee >(pbcopy)

or forget about using pipes altogether

pbcopy <~/.ssh/id_rsa.pub; pbpaste
1
  • While this works, isn't there a more "unixy" way to pipe to 2 commands in parallel?
    – linkyndy
    Commented Jul 7, 2016 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .