15 ms·
re: using Unix tools on Windows, I do like that you can pipe the output of a program in WSL to the Windows clipboard (clip.exe). I was really surprised by this!
by jxdxbx 3y ago
re: using Unix tools on Windows, I do like that you can pipe the output of a program in WSL to the Windows clipboard (clip.exe). I was really surprised by this! I use pbcopy on the Mac for this all the time.
- deleted 3y ago[deleted]
- TOMDM 3y agoOh wow, I didn't know about this, thanks for posting! For others, it really is just as easy as `ls | clip.exe` to pipe into your clipboard on WSL. `ls | tee clip.exe` if you want to print as well as copy. And of course you can just set an alias if you want to shorten clip.exe to clip. Great tip! Thank you!
- Brian_K_White 3y agoIt's implimented as a magic filename? Not a virtual or real file that actually appears in a filesystem? You don't have to do something like mount a virtual fs that maps to your host windows fs like a bind mount or nfs mount, and also add that fs to PATH? If so, that sounds terrible, and very Microsoft.
- Kwpolska 3y agoThe entire point of WSL is seamless integration. Windows drives are automatically mounted as /mnt/c, the Windows PATH is added to the Linux one, and it can run Windows .exe files and communicate with their standard I/O.
- Brian_K_White 3y agoSo it's not magic then. A fs and a field in PATH means nothing unexpected happens. So good then.
- chungy 3y agoCygwin also offers this through /dev/clipboard, bidirectional. You can do "cat /dev/clipboard > file.txt" as well as "ls > /dev/clipboard"
- wonger_ 3y agoBeware that clip.exe clobbers unicode. For example, `echo caña | clip.exe` sets the clipboard to `ca├a`. And there's no unclip.exe. You'd have to use `powershell.exe get-clipboard`, which is pretty slow. I use this simple alternative: https://github.com/equalsraf/win32yank https://github.com/equalsraf/win32yank `echo caña | win32clip.exe -i` and `win32yank.exe -o`
- adzm 3y agoI made a simple paste.exe utility for this actually. I suppose I should put it up on GitHub. Though win32yank pretty much does it all already.
- n_plus_1_acc 3y agoBeware of randomly truncated output https://github.com/microsoft/WSL/issues/4082 https://github.com/microsoft/WSL/issues/4082