Open bytemain opened 5 years ago
Can confirm.
Can also confirm. OS: Elementary OS 5.1, default Terminal.
not complaining. came here for this exact same issue only to realize it was open 1 year ago and nothing done... Either it was solved some where else or will not be solve.
I'm not sure how micro can detect that it is running in WSL rather than Linux, and therefore should use clip.exe
instead of xclip/xsel. In addition clip.exe
appears to only support copying and not pasting. Also, it appears support for OSC52 was recently merged into the WSL terminal (https://github.com/microsoft/terminal/pull/5823), and new versions of micro (nightly builds) support this if you set the clipboard
option to terminal
. It seems the WSL terminal only supports copying with OSC52 and not pasting (for security reasons).
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 xclip
which performs Windows commands to copy/paste. For example, I found this Github repository which seems to do this: https://github.com/Konfekt/xclip-xsel-WSL.
Thanks for the reply. I've look at different options with no avail. copy send command: xclip -in -selection clipboard, but don't know how to read the clipboard. The Github repo you pointed, didn't work for same reason, no access to the clipboard. If you want me to try a few thinks, let me know. More than open to help.
I was intrigued with a different behavior in nano vs micro. In nano, selection through mouse shows a "pale white" while selection in micro shows a "solid white". In nano, the "solid white" doesn't copy and thought copy-paste was more related to text selection rather than the proper commands. I did set mouse to false in settings and copy-paste works as expected in WSL2.
For anyone with similar issue: settings.json: { "autosu": true, "mouse": false, "tabsize": 2, "tabstospace": true }
No need to install xclip or xsel and ctr-c ctrl-v works perfect. Note: all mouse functionality is gone inside the editor (same as in nano). Not an ideal solution, but somewhat acceptable.
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):
#!/bin/bash
clip.exe <&0
I got Copy (and Paste) working by uninstalling xclip, and providing this as "xclip" in my path (~/.local/bin):
#!/bin/bash clip.exe <&0
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.
I got Copy (and Paste) working by uninstalling xclip, and providing this as "xclip" in my path (~/.local/bin):
#!/bin/bash clip.exe <&0
This causes clipboard to be cleared every time micro is opened for me.
Doing Ctrl+e and typing set clipboard terminal
makes copy/paste work fine on Windows Terminal Preview.
Doing Ctrl+e and typing
set clipboard terminal
makes copy/paste work fine on Windows Terminal Preview.
Works well with Windows Terminal 1.6.10571.0
I got Copy (and Paste) working by uninstalling xclip, and providing this as "xclip" in my path (~/.local/bin):
#!/bin/bash clip.exe <&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 https://github.com/microsoft/WSL/issues/4852
Personally, I found ctrl +e
and set clipboard terminal
to work perfectly fine, but if for someone it's not working well please see my comment for an alternative tool that works better than clip.exe: https://github.com/microsoft/WSL/issues/4852#issuecomment-606497383
Personally, I found
ctrl +e
andset clipboard terminal
to work perfectly fine, but if for someone it's not working well please see my comment for an alternative tool that works better than clip.exe: microsoft/WSL#4852 (comment)
@sinapis, since ctrl +e
and set clipboard terminal
didn't work for me, I installed utf8clip according to your instruction in your WSL comment.
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. If that doesn’t solve the issue try external. When setting external you will also need to configure someplace which clipboard tool should be used. Another option is to create a “fake” xclip just like you see in this thread above but call utf8clip inside the actual script
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 terminal
.
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 xclip
file, but no success.
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 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 https://github.com/zyedidia/micro/commit/03ae049c0fe5862ca6010474dd775656bd6e5b86
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 xclip
somewhere on your path, and don't forget to make it executable
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