Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Beware 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

`echo caña | win32clip.exe -i` and `win32yank.exe -o`


I 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.


Cygwin also offers this through /dev/clipboard, bidirectional. You can do "cat /dev/clipboard > file.txt" as well as "ls > /dev/clipboard"


Oh 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!


It'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.


The 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.


So it's not magic then. A fs and a field in PATH means nothing unexpected happens.

So good then.


Beware of randomly truncated output https://github.com/microsoft/WSL/issues/4082




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: