WSL: Pipe Output to the Windows Clipboard

This blog post explains how you can pipe output to the Windows clipboard under Windows Subsystem for Linux (WSL). This is a repost of

You can use the clip.exe command to stream text from a shell command to the Windows clipboard. I use this technique in Windows Terminal with Windows Subsystem for Linux (WSL).

Because Unix interprets the commands clip and clip.exe as two different things, you may want to add a clip alias to the ~/.bashrc file ().

alias clip="clip.exe"

Then you can stream to the clipboard.

Console showing use of clip alias
$ which clip.exe
$ alias clip=clip.exe
$ grep alias .bashrc | clip
$ which paste.exe
$ vi aliases.txt #paste
$ man bash | clip
$ touch bash.docx ; winword bash.docx #paste

Unfortunately, there is no paste.exe.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: