Like me, you might not have known this handy Windows 11 clipboard terminal trick for PowerShell and WSL

Piping the contents of a .bashrc file to the Windows 11 clipboard from WSL
Piping text from Linux to the Windows 11 clipboard is a great example of how WSL integrates the two (Image credit: Windows Central)

The terminal is one of those places that looks scary to many, though it really isn't. But others absolutely live in there, be that for work such as system admin, or you might just be a massive nerd (like me) who finds it weirdly enjoyable. Or any number of reasons in between. The terminal is a powerful tool in any PC user's arsenal. 

You'll always learn something new, too, like this little nugget shared on Reddit by Microsoft's Jen Gentleman

It details sending the outputs of commands entered into the terminal directly to the Windows 11 clipboard, where you can then paste to any other app you need to. If you know you're going to be outputting a lot of text, this is a handy time saver. Here's how to do it. 

Tip of the week: Use clip to pipe the output of your command to the clipboard from r/Windows11

How to copy command outputs to the clipboard from PowerShell, Command Prompt and WSL 

The best part of this is that it doesn't matter whether you're using PowerShell, Command Prompt or the Windows Subsystem for Linux (WSL), it all works the same. All you have to use is "Clip" after the command, which will send its output directly to the clipboard. 

There are mild differences between PowerShell/Command Prompt and WSL, though. In the first two, you would pipe to clip after the command. In WSL, you need to pipe to clip.exe, which tells Linux to interact with the clipboard on the host system. 

So, for example, if I'm in WSL and I wanted to quickly copy the contents of my .bashrc file to the clipboard, I'd enter this in the terminal: 

cat ~/.bashrc | clip.exe

When the text has been copied to the clipboard you can quickly paste it into any app, no need for trying to select and copy text. As long as you remember the all important pipe (|) it'll get sent straight to the clipboard. 

Personally, it's not something I'll need all the time, but there have been occasions I've really needed something like this and never knew it existed. I like to keep a backup of changes I've made to my .bashrc file, for example, and this will definitely help with that. Hopefully it'll help out a few of you, too!

Richard Devine
Managing Editor - Tech, Reviews

Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you'll find him steering the site's coverage of all manner of PC hardware and reviews. Find him on Mastodon at mstdn.social/@richdevine