WSL Clipboard: Copy and Paste Between Linux and Windows
WSL uses the normal Windows clipboard, so text you copy in a WSL terminal tab can be pasted into any Windows app and the other way round. In Windows Terminal, select text and press Ctrl+C or Ctrl+Shift+C to copy, and Ctrl+Shift+V to paste. From a bash script, pipe text to clip.exe to copy it and call powershell.exe to read the clipboard. Three things don't translate on their own: Windows file paths, CRLF line endings, and non-ASCII text sent through clip.exe.
Copy and paste in the terminal
The terminal window is a Windows app, so its copy and paste go straight to the Windows clipboard whatever shell is running in the tab. In Windows Terminal's default key bindings:
| Action | Keys |
|---|---|
| Copy selected text | Ctrl+C (only when text is selected), Ctrl+Shift+C, Ctrl+Insert or Enter |
| Paste | Ctrl+V, Ctrl+Shift+V or Shift+Insert |
| Select with the keyboard | Ctrl+Shift+M (mark mode) |
| Copy by right-click | Right-click copies a selection; with nothing selected, right-click pastes |
Because a copy from the terminal lands on the Windows clipboard, it also shows up in Windows clipboard history (Win+V) if you've turned that on. Copying plain text from Windows Terminal covers selection and formatting options, and pasting into Windows Terminal safely explains the warning you get when pasting several lines into a shell.
Linux GUI apps that run through WSLg also share copy and paste with Windows apps.
Copy command output to the Windows clipboard
WSL can run Windows programs by name, including the .exe extension, and you can pipe to them like any other command. Microsoft's own example:
cat /etc/hosts | clip.exe
This works well for plain ASCII text such as most code, logs and paths.
Why clip.exe garbles accents, emoji and box-drawing characters
clip.exe doesn't read its input as UTF-8. It decodes piped bytes using the Windows console's legacy code page, so any non-ASCII character in UTF-8 text comes out wrong: ✨ can become Γ£¿, accented letters turn into pairs of odd symbols, and tree output loses its line-drawing characters.
To copy UTF-8 text correctly, have PowerShell read it from a file as UTF-8 and set the clipboard itself. Add this to ~/.bashrc:
# Copy stdin to the Windows clipboard as UTF-8
wclip() {
local tmp
tmp="$(mktemp)"
cat > "$tmp"
powershell.exe -NoProfile -Command "Get-Content -Raw -Encoding UTF8 -LiteralPath '$(wslpath -w "$tmp")' | Set-Clipboard"
rm -f "$tmp"
}
Then use it like clip.exe:
tree | wclip
git log -5 --oneline | wclip
It's slower than clip.exe because it starts PowerShell, so keep clip.exe for quick ASCII copies if you prefer. The PowerShell clipboard cheat sheet covers Set-Clipboard and Get-Clipboard in more detail, and copying a git commit message with its line breaks shows the same pipe used on a full commit body.
Read the Windows clipboard from bash
There's no Linux command that reads the Windows clipboard, so ask PowerShell:
# Paste the Windows clipboard to stdout, with Windows line endings removed
wpaste() {
powershell.exe -NoProfile -Command '[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Get-Clipboard -Raw' | tr -d '\r'
}
Two details make this work:
tr -d '\r'removes the carriage returns from Windows CRLF line endings. Without it, a pasted path or command ends with an invisible\rand fails, often with a confusing "No such file or directory".- Setting
[Console]::OutputEncodingto UTF-8 stops non-ASCII characters being mangled on the way out of PowerShell.
Usage:
wpaste > notes.txt
wpaste | jq .
If you're used to macOS, you can name these pbcopy and pbpaste instead.
Convert paths between Windows and WSL
Paths don't translate when you paste them. C:\Users\you\project means nothing to bash, and /home/you/project means nothing to File Explorer. Use wslpath inside WSL:
# Windows path to WSL path
wslpath 'C:\Users\you\project\file.txt'
# /mnt/c/Users/you/project/file.txt
# WSL path to Windows path
wslpath -w /home/you/project/file.txt
# \\wsl.localhost\Ubuntu\home\you\project\file.txt
# Windows path with forward slashes
wslpath -m /mnt/c/Users/you/project/file.txt
# C:/Users/you/project/file.txt
Put Windows paths in single quotes so bash doesn't treat the backslashes as escape characters. Use wslpath rather than building /mnt/c/... by hand, because the mount location can be changed in /etc/wsl.conf.
Jump to a folder you copied in File Explorer
In Windows 11 File Explorer, Ctrl+Shift+C (or Copy as path) copies the path with double quotes around it. Strip the quotes and convert it:
cd "$(wslpath "$(wpaste | tr -d '"')")"
The reverse is often simpler: run explorer.exe . in WSL to open the current folder in File Explorer. Copying a file path that works in the terminal covers other shells.
What doesn't cross between WSL and Windows
- Copied files. Copying a file in File Explorer puts a file list on the clipboard, not text, so there's nothing for a bash command to read. Copy the path instead and use
wslpath. - Images.
clip.exeand the functions above handle text only. Save images to a file and use the path; Linux GUI apps under WSLg can use the shared clipboard instead. - Rich text. Formatting from Word or a browser arrives in the terminal as plain text, because terminals paste plain text only.
Large output: use a file instead
For large logs or data, a file is easier to handle than the clipboard. Save it in your WSL home folder and open it from Windows at \\wsl.localhost\<distro>\home\<you>\..., or run explorer.exe . to open the folder. Microsoft notes that crossing file systems this way is slower than native access, which matters for builds and repositories but not for opening a single file.
Column-aligned output, such as a hex dump from xxd, can go through the clipboard but needs a fixed-width font at the other end; see how to copy hex dumps without losing alignment.
FAQ
Why does Ctrl+V not paste in my WSL terminal?
In Windows Terminal, Ctrl+V and Ctrl+Shift+V both paste by default. If neither works, check whether your Windows Terminal settings reassign them, or right-click to paste.
Can I use xclip or xsel in WSL?
They need a Linux display server. Under WSLg, Linux GUI apps share the clipboard with Windows, but for command-line use, clip.exe and powershell.exe are the dependable options.
Does PowerShell's Set-Clipboard work from WSL?
Yes, through powershell.exe -Command, as in the wclip function. Pass the text through a file rather than stdin, because PowerShell may decode piped input with the system code page too.
Related reading
- Windows Terminal: Copy Plain Text Without Formatting
- How to Copy a File Path That Works in the Terminal
- PowerShell Clipboard Cheat Sheet: Get-Clipboard and Set-Clipboard
- Clipboard Tips for Developers on Windows
Sources
- WSL interop (Microsoft Learn) — running Windows executables from WSL,
cat /etc/hosts | clip.exe, wslpath examples, performance and mount notes. - Working across file systems (Microsoft Learn) — /mnt/c, \\wsl$, explorer.exe from WSL.
- Windows Terminal actions (Microsoft Learn) — copy, paste and mark mode bindings.
- Windows Terminal interaction settings (Microsoft Learn) — right-click copy and paste behaviour.
- Set-Clipboard (Microsoft Learn) and Get-Clipboard (Microsoft Learn) — the cmdlets the functions call.
- clip (Microsoft Learn) — the clip command.
- WSLg (GitHub) — copy and paste between Linux GUI apps and Windows.
- Fix garbled copied text with tmux-yank in WSL 2 (Nick Janetakis) — clip.exe mangling non-ASCII UTF-8 characters.
Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge Drop vs Win+V · Support
Free · Lightweight · Privacy First