Cygwin 命令复制到 Windows 剪贴板

我在这里看到:

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

在 linux 和 osx 中有一种从命令行复制到剪贴板的方法。所以我运行了 cygwin setup.exe 但找不到 xsel 包。我猜这个包裹没有被移植到窗户上吧?看起来有个工具可以在窗口里做到这一点:

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

我想我会试试——但是我想问问是否有人找到了一个好的解决办法。

29534 次浏览

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.

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

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

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

getclip/putclip is found in cygutils-extra package.

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

what about just

clip < file.extension

just tried in on my ssh key