zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.86k stars 1.17k forks source link

Clipboard from SSH #2238

Open scargill opened 2 years ago

scargill commented 2 years ago

I'm sure this isn't a new problem but it is new to me. I installed micro on Raspberry Pi 4 just this week using:

curl https://getmic.ro | bash

Up to date PI OS and up to date Windows - all works PERFECTLY - and I use the editor in an SSH session from Windows - the clipboard from Windows to the editor is failing completely. Yet on the main MICRO page we see:

As its name indicates, micro aims to be somewhat of a successor to the nano editor by being easy to install and use. It strives to be enjoyable as a full-time editor for people who prefer to work in a terminal, or those who regularly edit files over SSH.

Nano copies and pastes back and forth to Windows no problem..

Ideas?

Specifications

Commit hash: OS: Terminal:

pkitszel commented 2 years ago

Same here, but from linux host to other linux machine. xsel, xclip installed on both machines

tested on kitty and urxvt terminals.

micro v2.0.9 and v2.0.10

> show clipboard yields "external"

pkitszel commented 2 years ago

I managed to fix this for my case, X forwarding was needed.

So, when starting ssh session, you need to enable X11 forwarding, as described in #305, so just ssh -X followed by your usual args.

scargill commented 2 years ago

I've been listening to this subject since I first discovered the otherwise excellent MICRO maybe a year or so ago. I use Windows 10 64 bit (11 as of yesterday) and Mobaxterm for SSH. Clipboard exchanges between Micro on my fully up to date Raspberry Pi ~(running micro as user pi) and Windows - are not a pleasant experience at all. I wonder if there is a definitive way around this. Windows users have decades of experience of control-C for copy and control-V for paste - I wonder if anyone can sort this issue out. I for one would not have a clue how ro initiate "X11 forwarding" as I simply press a button in Mobaxterm and select the IP address or hostname of the Pi to start the session., however, X-11 forwarding (in ADVANCED SETTINGS" is pre-ticked in Mobaxterm - always has been. Doesn't help me with copy and paste. image

pkitszel commented 2 years ago

Could you start any GUI app, eg xterm? If not, problem is not related to micro :)

scargill commented 2 years ago

The gui on the Pi is not turned on as I use SSH to talk to the Pi from my PC (Mobaxterm - as above - x11-forwarding is enabled).

scargill commented 2 years ago

With xcel and xclip installed on the SSH-connected RPI, I just went into a text file in micro and used control-C to copy a part of the text. The bottom of the editor ssid "Copied selection". However as I went back to my PC and used control-V in Notepad++ - what was pasted was a URL I copied in Windows half an hour ago - so the clipboard from the RPI didn't get copied across to the PC. Further 0 Windows WIN+V shows all the items recently put into the clipboard and that does not include the RPi clipboard. So - I copied part of this message in Windows to the clipboard and what was pasted back into the RPI text file was the material originally copied in RPI, nothing from Windows... yet in NANO this all aorks seamlessly - no conditions. I'm not defending nano as, from a Windows user perspective it is awful compared to micro - APART from this important clipboard issue.

scargill commented 2 years ago

In Windows - if I take the text "this is it" and copy it.... and then SSH to my RPi, the centre mouse button (no as good as Ctrl-V but do-able) pastes that text straight into the RPI command line or if NANO is open - straight into NANO. Vice-versa, This piece of text "lua:comment" was just pasted into Windows Github from the RPI NANO editor. All works as it should - but not in MICRO.

cocoshka commented 2 years ago

Forcing micro to use terminal clipboard worked for me!

Just run with option micro -clipboard terminal or edit your micro config at ~/.config/micro/settings.json

{
    "clipboard": "terminal"
}
scargill commented 2 years ago

Forcing micro to use terminal clipboard worked for me!

Just run with option micro -clipboard terminal or edit your micro config at ~/.config/micro/settings.json

{
    "clipboard": "terminal"
}

Well, I just installed micro on a new RPi, tried both of the above options and now on my PC (which connects to the RPi via SSH using Mobaxterm) - when I do my usual centre or right mouse button - which DOES paste into the likes of NANO, when I try "./micro -clipboard terminal" and do the same operation with the mouse, I get a line at the bottom of micro, black lettering, brown background which says "No clipboard received from terminal"

So, copy in Windows - move to SSH session, open nano, hit right-mouse, the content is pasted in. Close nano, open micro, right-click or centre click mouse - nothing comes in. Close micro, open nano, right-click mouse - that PC content still comes in.

This really needs resolving somehow....

nkrepo commented 2 years ago

Forcing micro to use terminal clipboard worked for me!

Just run with option micro -clipboard terminal or edit your micro config at ~/.config/micro/settings.json

{
    "clipboard": "terminal"
}

I had the same issue. Forcing micro to use terminal clipboard worked for also. I am using micro 2.0.10 on Ubuntu 22.04 over Powershell Openssh with Windows Terminal.

ca5ua1 commented 2 years ago

Arch, KDE, Konsole Host and remote machine - wayland.

Don't work at all. No X11 forwarding, no installed clipboard tools, no different clipboard options helps. Shift won't work either. Remote machine only work with own clipboard, konsole prevent copying to host clipboard.

With X11 forwarding, clipboard can be extracted with xclip -o thou still don't copies to host machine by its own. So, the workaround can be: https://stackoverflow.com/a/49890019 and its equivalents. Still pretty messy

visortelle commented 2 years ago

Trying to use micro with https://github.com/sorenisanerd/gotty and https://github.com/xtermjs/xterm.js/

Tried all the -clipboard options. Clipboard paste works. The clipboard copy doesn't work.

Vim and nano in the same scenario work well.

Probably awaiting for this https://github.com/xtermjs/xterm.js/issues/3260

mrx23dot commented 2 years ago

None of these work for me on Win+Kitty: clipboard external terminal

why does it work without problem on nano? (no X11 setting is needed)

Shura0 commented 2 years ago

I have the same issue with ssh access. Home PC runs Ubuntu, remote PC runs Debian. Shell is zsh on both sides, xclip and xset are installed, but anyway micro gets error: System clipboard not found, install xclip/xsel.

hansratzinger commented 2 years ago

Same for me. Using DietPi/ARMv8 64 on a Raspery Pi4 with xclip installed. Starting with micro -clipboard terminal does not work either. Copy/Paste works only in Linux not via SSH to Win10.

scargill commented 2 years ago

October 2021 I first started this topic - it's looking like this isn't going to get fixed... I've reverted to other editors... shame.

pkitszel commented 2 years ago

Just noting that I've switched to > set clipboard terminal, and it works for me again (but I need use keyboard shortcut, scroll click not enough anymore).

@scargill , you know, it's a wider problem, not project specific

emidevops commented 1 year ago

No copy even with "set clipboard terminal" on Debian 11 (micro version : 2.0.8-1+b6).

dzalf commented 11 months ago

Hi guys

Any updates regarding this issue?

Facing the same problem:

System clipboard not found, install xclip/xsel or change 'clipboard' option

Changing the clipboard to terminal does NOT solve the problem on a RPi Zero W over SSH (puTTY)

Please solve this 🙏

dimkasta commented 11 months ago

So far the only thing that works for me is to set "mouse": false on settings.json. Then micro behaves exactly like the rest of terminal apps, with right click opening a context menu or directly pasting, depending on your ssh/terminal settings. It's a bummer to lose the click to move and click to multi-cursors though, but keybindings are kinda faster... Once you learn to move with the keyboard

hgraur commented 6 months ago

Environment: Windows 10 with Putty I've tried with adding the "clipboard": "terminal" but it does not work. The solution that I'm using is to press the Ctrl keypad while right clicking on the mouse. It will present the context menu where you can choose "Paste" and it works.

This way you don't have to disable mouse in micro.

dimkasta commented 6 months ago

@hgraur nice. I just tried it and it works nicely.

On Windows 11 and git-bash I have to use shift though instead of ctrl

You can also use shift+Ins to paste from the host

Diomas commented 3 months ago

I've just discovered Ctrl+Shift+V does work with clipboard=terminal on debian with no x-forwarding, no xsel, no xclip (host is ubuntu)

pkitszel commented 2 months ago

copying stopped working for me, but I have figured out how to fix, so, in my case the solution is to: use ssh -X on your local side, ensure there is xsel and xauth installed on the remote side, and use set clipboard external there.

scargill commented 2 months ago

Regards

Pete

Peter Scargill

https://tech.scargill.net

Calle Ceuta 14

Galera

Granada 18840

Spain

+34 634 326331

On 4 Jul 2024 at 13:09, Przemek Kitszel @.***> wrote:

hmm, copying is not working for me too over ssh, all three modes of clipboard, also with/without X forwarding. Other thing that is not working is Ctrl+arrows.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>