cygwin command to copy to windows clipboard

Cygwin

Cygwin Problem Overview


I see here:

http://www.pgrs.net/2008/1/11/command-line-clipboard-access

that there's a way in linux and osx to copy to the clipboard from the command line. So I ran my cygwin setup.exe, but couldn't find the xsel package. I'm guessing maybe this package hasn't been ported to windows? Looks like there's a tool to do it in windows:

http://www.labnol.org/software/tutorials/copy-dos-command-line-output-clipboard-clip-exe/2506/

I guess I'll try that - but in the mean I figured I'd ask if anyone has found a good solution.

Cygwin Solutions


Solution 1 - Cygwin

Cygwin comes with special device file called /dev/clipboard:

echo foobar > /dev/clipboard  # Puts "foobar\n" on the clipboard
cat /dev/clipboard  # Pastes clipboard to stdout

Solution 2 - Cygwin

On the page you linked, there are comments hinting how to do it on windows:

> On Windows, Cygwin comes with getclip > and putclip which do the same job.

Solution 3 - Cygwin

I second the answer above

To cat text to the Windows clipboard

putclip < foo.txt

To pipe to a file whatever text is in the Windows clipboard

getclip > foo.txt

Solution 4 - Cygwin

getclip/putclip is found in cygutils-extra package.

Solution 5 - Cygwin

what about just

clip < file.extension

just tried in on my ssh key

Solution 6 - Cygwin

Actually google "resource kit clip " for your windows clip and in cygwin terminal ( I use puttycyg works the following: find | clip

Solution 7 - Cygwin

Not exactly Ditto, but here's a clibboard logger.

#!/usr/bin/ksh
while true
do
    if [[ "$(</dev/clipboard)" = "${LastClip}" ]]
    then
            sleep 2
    else
            LastClip="$(</dev/clipboard)"
            echo "$(</dev/clipboard)" >> $HOME/cliplog.txt
            sleep 1
    fi
done

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionandersonbd1View Question on Stackoverflow
Solution 1 - CygwinAdam RosenfieldView Answer on Stackoverflow
Solution 2 - CygwinAndre MillerView Answer on Stackoverflow
Solution 3 - Cygwinuser78706View Answer on Stackoverflow
Solution 4 - CygwinyskkinView Answer on Stackoverflow
Solution 5 - CygwinBenjamin SweetnamView Answer on Stackoverflow
Solution 6 - CygwinYordan GeorgievView Answer on Stackoverflow
Solution 7 - CygwinCharles SteppView Answer on Stackoverflow