pbcopy for Windows?

Use something like:

someCommand | clip

That will pipe the result to the windows clipboard


I'm using the Git Bash command shell for Windows, and as someone noted above, using clip is very annoying, because it also copies the carriage return at the end of the output of any command. So I wrote this function to address it:

function cpy {
while read data; do     # reads data piped in to cpy
    echo "$data" | cat > /dev/clipboard     # echos the data and writes that to /dev/clipboard
done
tr -d '\n' < /dev/clipboard > /dev/clipboard     # removes new lines from the clipboard
}

So for example:

$ pwd | cpy  # copies directory path

$ git branch | cpy # copies current branch of git repo to clipboard

Just for reference I had to copy my public key directly after Bitbucket was giving me a bad key warning. I was able to use @soandos answer like so:

cat ~/.ssh/id_rsa.pub | clip to copy my key directly from the command line on a PC. (since command line sucks compared to terminal)