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!

CATEGORIES
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

Read more
Command Prompt commands
20 Essential commands every user should know on Command Prompt for Windows 11
PowerShell basic commands
15 Essential PowerShell commands every Windows 11 user should know
Powertoys Run
7 reasons you simply HAVE to use PowerToys Run on your Windows 11 PC
Open Command Prompt on Windows 10
How to launch Command Prompt (standard and admin) on Windows 10
Microsoft PowerToys logo
I would have paid money for this new PowerToys feature. But you can get it for free.
Windows 11 File Explorer Hero
Windows 11 file sharing could be transformed by this hidden feature, especially if you have a Surface Pro
Latest in Software Apps
Excel spreadsheet with checkboxes
Microsoft 365 sales are few and far between these days — grab this one before it goes away!
Office 365 on Razer laptop
Microsoft 365's best apps are about to get a speed boost — here's when the rollout begins
Photo of Microsoft's new sign-in page for Xbox.com using the Microsoft Edge browser.
Over one billion users will get a new Microsoft user experience, and it has a dark mode
Windows 11 answer file
How to easily create an unattended answer file for Windows 11
ChatGPT logo is seen displayed on a smartphone screen next to a laptop keyboard.
I love ChatGPT-4o's unhinged image-generation capabilities — but I'm afraid imminent censorship by OpenAI lurks on the horizon
Bill Gates, co-chairman of the Bill and Melinda Gates Foundation, delivers a keynote speech on the closing day of the Global Solutions Summit in Berlin, Germany, on Tuesday, May 7, 2024.
Bill Gates says "AI will replace humans for most things" — Rendering doctors and tutors obsolete within a decade
Latest in How-to
Atomfall
Can I play Atomfall on Steam Deck, ROG Ally, and other gaming handhelds?
Windows 11 answer file
How to easily create an unattended answer file for Windows 11
The First Berserker: Khazan
Is The First Berserker: Khazan on Xbox Game Pass?
Clair Obscur: Expedition 33
Is Clair Obscur: Expedition 33 on Xbox Game Pass?
A close-up of Hazel in South of Midnight
Is South of Midnight on Xbox Game Pass?
Atomfall screenshot
Atomfall: How to grab the best melee weapon and melee perk right away