Saturday, June 29, 2019

Copying to Clipboard with Windows Subsystem for Linux

Copying to Clipboard with Windows Subsystem for Linux

EmailThis Premium lets you save unlimited bookmarks, PDF, DOCX files, PPTs and images. It also gives you a PDF copy of every page that you save. Upgrade to Premium →

This tip is 100% thanks to Ben Hillis, a developer working on the Windows Subsystem for Linux (WSL). Yesterday I needed to copy a file under WSL to the my system clipboard. If you Google for how to do this, you'll see a CLI called clip that works under Unbuntu, however, that doesn't work under WSL. If I had to guess I'd say because there's isn't a GUI involved with WSL but to be honest, I'd be guessing.

When I asked on Twitter, Ben had a simple solution - use clip.exe. I keep forgetting that WSL provides complete access to Windows executables. I knew this - heck - it's how my tip on loading VSCode Insiders from WSL worked. But I didn't even think to check if Windows had a utility to copy to the clipboard.

In case you're curious, this is how you would copy a file under WSL to your Windows clipboard:

cat report.txt | clip.exe 

And I'm sure there's numerous other ways too. Anyway, I'm mainly just blogging this so I don't forget.

Source: https://www.raymondcamden.com/2017/10/19/copying-to-clipboard-with-windows-subsystem-for-linux

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade to Premium

No comments: