18

I like to use utilities like pbpaste on mac and xclip on linux to copy from the command line to the clipboard. I'm using windows system for linux (WSL). Is there any way of getting this behaviour from WSL. That is, I want a command line CLIP so that if I run the following in a WSL linux command line the output is written to clipboard:

ls | CLIP
3
  • 2
    Does this answer your question? Use clipboard through WSL?. Just a reminder to always search for an existing question/answer before asking a new one. While I understand that sometimes they are hard to find, this was the first result when searching the site for "wsl clipboard". Thanks! Nov 21, 2021 at 20:51
  • Hmm... not sure how I missed that. I tired that clip.exe command before and it didn't work. But let me retry when I'm back on my windows machine. Shall we close this question as a duplicate?
    – Att Righ
    Nov 22, 2021 at 14:32
  • Wait until you try it out - It does need the .exe extension on it, so maybe that's what you missed? But yes, if that works, I'd recommend accepting that other answer as the duplicate. Thanks! Nov 22, 2021 at 14:44

2 Answers 2

24

You may call Windows executables in WSL, only that you need the full file-name:

ls | clip.exe

Note that, unlike under Windows, the .exe part is required in WSL.

4
  • How about CLIP.EXE vs clip.exe? (Curious!)
    – Hannu
    Nov 21, 2021 at 18:58
  • @Hannu: Just tried it - it works.
    – harrymc
    Nov 21, 2021 at 19:03
  • i.e. both works. Right the idiosyncrasies...
    – Hannu
    Nov 21, 2021 at 19:05
  • Unfortunately, clip.exe absolutely wrecks anything that's not ASCII, because Windows has not discovered UTF-8 yet. :(
    – lindhe
    Feb 19 at 18:06
-1

try this

ls | clipcopy
clippaste

can use on Windows with ctrl+V

3
  • 1
    Welcome to Super User! I'm not aware of clipcopy and clippaste being standard Linux commands. They certainly aren't available in my Ubuntu 22.04 WSL install. If there are additional instructions or dependencies needed for your answer to work, please edit it to include them. Thanks! Jan 3 at 15:57
  • Sorry, is from oh-my-zsh clipcopy is a shell function from /home/liubin/.oh-my-zsh/lib/clipboard.zsh if you use zsh, maybe can use it (clipboard.zsh on github)[github.com/ohmyzsh/ohmyzsh/blob/master/lib/clipboard.zsh]
    – liubin
    Jan 5 at 6:05
  • Unfortunately, when I run echo abcåäö | clipcopy, the clipboard gets populated with useless junk: abc├Ñ├ñ├╢ ☹️
    – lindhe
    Feb 19 at 18:09

Not the answer you're looking for? Browse other questions tagged .