-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WSL] Copy doesn't work #1365
Comments
Can confirm. |
Can also confirm. |
not complaining. came here for this exact same issue only to realize it was open 1 year ago and nothing done... |
I'm not sure how micro can detect that it is running in WSL rather than Linux, and therefore should use Unfortunately I don't use WSL (maybe I should install it though) so it is difficult for me to test. Perhaps it is possible to make a script on your system called |
Thanks for the reply. I've look at different options with no avail. |
I was intrigued with a different behavior in nano vs micro. For anyone with similar issue: No need to install xclip or xsel and ctr-c ctrl-v works perfect. |
Yes it's always possible to disable the mouse in micro and fall back to your terminal emulator's selection and copy/paste. The drawback is that the terminal emulator has no concept of multiple splits holding different text, and line numbers not being part of the text. |
I got Copy (and Paste) working by uninstalling xclip, and providing this as "xclip" in my path (~/.local/bin):
|
Thanks for this. It sorta works, but isn't a perfect solution. I'm using Debian 1.2.0.0 (from the Microsoft Store) on Windows 10 1909 with WSL2 and Windows Terminal 1.4.3243.0. With your ~/.local/bin/xclip, paste from Micro to Micro has issues. The standard Ctrl+c then Ctrl+v doesn't work. Ctrl+c then Ctrl+Shift+v will work, but it will only paste to the cursor; i.e., not if you have something highlighted you're trying to replace. If you try it, you lose whatever is in the clipboard and have to copy it again. You also lose the contents of the clipboard if you accidentally hit Ctrl+v (instead of Ctrl+Shift+v). A couple more notes to those trying this: Don't forget to chmod +x ~/.local/bin/xclip. Also, in Debian, the Windows paths aren't exposed in the environment. So add them to your bash profile or simply hard code the path to /mnt/c/Windows/System32/clip.exe in the script. |
This causes clipboard to be cleared every time micro is opened for me. |
Works well with Windows Terminal 1.6.10571.0 |
I had to move the script to /usr/local/bin because ~/.local/bin wasn't in the path when doing wsl micro, works perfectly so far |
not sure using clip.exe is a good idea. It corrupts the text in certain scenarios. See microsoft/WSL#4852 |
Personally, I found |
@sinapis, since Copy from a Windows app and paste in micro now works, but copy in micro and paste in micro doesn't (it always pastes what I have last copied in Windows). Is there any trick to copy in micro and paste in micro? |
@frankydee try to set clipboard to internal. |
I've still not found a viable solution, although my experience is a bit different than what's been described so far. Using Ubuntu 20.04 WSL2, I have no trouble copy/pasting with micro when it's opened in Windows terminal. Everything seems to work fine with the clipboard set to However, this is not the case in VSCode's integrated terminal. In there, copying gives a success message but does not copy. Pasting still works though. I've tried turning mouse off, and I've tried the trick with the |
I have not tested this but try https://stackoverflow.com/a/69928270 |
Thanks @mateuszkozakiewicz , but maybe I wasn't as clear as I should have been. Copy/pasting works fine in VSCode integrated terminal accept when I have micro opened in it. |
This will probably be fixed in the next release since we got 03ae049 But in the meantime, I found this to work: #!/bin/sh
if [ "$1" = "-in" ]; then
powershell.exe '$Input | Set-Clipboard'
else
powershell.exe Get-Clipboard
fi Put it in a file called |
Description of the problem or steps to reproduce
In the WSL(Windows Subsystem Linux), Select something and press Ctrl+C
the result show:

but actually copy failed.
WSL can use the windows' clip.exe to copy content.
Specifications
You can use
micro -version
to get the commit hash.Commit hash: 3a8898d
OS: Arch WSL2(
Linux version 4.19.55-microsoft-standard (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP Fri Jun 28 20:53:12 UTC 2019
)Terminal: Cmder
The text was updated successfully, but these errors were encountered: