从 linux 子系统中的剪贴板管道 windows
Pipe from clipboard in linux subsytem for windows
使用 Linux 子系统 Windows (LSW),clip.exe
可用于将数据复制到 windows 剪贴板:
$ clip.exe /?
CLIP
Description:
Redirects output of command line tools to the Windows clipboard.
This text output can then be pasted into other programs.
Parameter List:
/? Displays this help message.
Examples:
DIR | CLIP Places a copy of the current directory
listing into the Windows clipboard.
CLIP < README.TXT Places a copy of the text from readme.txt
on to the Windows clipboard.
有什么方法可以将 FROM 传送到剪贴板吗?预期用途示例:
$ paste.exe > foo.txt
$ paste.exe | tr , '\n' | clip.exe
解决方案
这会将 Windows' 剪贴板打印到标准输出:
powershell.exe Get-Clipboard
例子
$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello
$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13
$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world
paste() { # Add me to your .bashrc, perhaps.
powershell.exe Get-Clipboard | sed 's/\r//'
# The `sed` will remove the unwelcome carriage-returns
}
来源:https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532
使用 Linux 子系统 Windows (LSW),clip.exe
可用于将数据复制到 windows 剪贴板:
$ clip.exe /?
CLIP
Description:
Redirects output of command line tools to the Windows clipboard.
This text output can then be pasted into other programs.
Parameter List:
/? Displays this help message.
Examples:
DIR | CLIP Places a copy of the current directory
listing into the Windows clipboard.
CLIP < README.TXT Places a copy of the text from readme.txt
on to the Windows clipboard.
有什么方法可以将 FROM 传送到剪贴板吗?预期用途示例:
$ paste.exe > foo.txt
$ paste.exe | tr , '\n' | clip.exe
解决方案
这会将 Windows' 剪贴板打印到标准输出:
powershell.exe Get-Clipboard
例子
$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello
$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13
$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world
paste() { # Add me to your .bashrc, perhaps.
powershell.exe Get-Clipboard | sed 's/\r//'
# The `sed` will remove the unwelcome carriage-returns
}
来源:https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532