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

As a seasoned researcher and avid terminal user, I can’t help but be excited about this little-known feature shared by Microsoft’s Jen Gentleman on Reddit. The ability to send command outputs directly to the clipboard is a game changer for anyone frequently working in PowerShell, Command Prompt, or the Windows Subsystem for Linux (WSL).


As a researcher delving into the world of computing, I can’t help but appreciate the raw power and versatility of the terminal. Although it may appear intimidating to some, I find solace in its command-line interface. Whether you’re a professional system administrator or simply an enthusiast drawn to its unique charm, the terminal is an indispensable tool for navigating the depths of your PC’s operating system.

Microsoft’s Jen Gentleman recently shared an enlightening tidbit on Reddit, and you’re sure to pick up something new as well.

As someone who spends hours in front of a terminal window every day, I can’t stress enough the convenience of being able to copy command output directly to my clipboard in Windows 11. This little-known feature has significantly streamlined my workflow and saved me countless minutes each week.

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 

Regardless of whether you opt for PowerShell, Command Prompt, or the Windows Subsystem for Linux (WSL), the experience remains consistent. To transfer command output straight to your clipboard, simply include “Clip” as part of your command.

In PowerShell and Command Prompt, there are subtle distinctions, but when it comes to redirecting output to the clipboard using a pipe, you would place the command followed by “| clip” at the end. Conversely, in WSL (Windows Subsystem for Linux), you need to insert “clip.exe” in between, resulting in a sequence like “command | clip.exe”. The latter instructs Linux to engage with the host system’s clipboard.

For instance, suppose you are working in the WSL (Windows Subsystem for Linux) environment and need to swiftly copy the content of your .bashrc file into your clipboard. In such a case, you would input the following command in the terminal:

cat ~/.bashrc | clip.exe

Once you’ve copied a text using the pipe symbol (|), pasting it into various applications becomes effortless – there’s no need for laborious selection and copying processes.

From my perspective, there aren’t many instances when I require this specific functionality, but when I do, I’m grateful it exists. Take backups of modifications to my .bashrc file being one such instance. This tool is sure to be beneficial for me and perhaps a few others as well!

Read More

2024-07-29 18:09