pbcopy for Windows?
Solution 1:
Use something like:
someCommand | clip
That will pipe the result to the windows clipboard
Solution 2:
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