micro icon indicating copy to clipboard operation
micro copied to clipboard

Clipboard from SSH

Open scargill opened this issue 4 years ago • 29 comments
trafficstars

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:

scargill avatar Oct 06 '21 07:10 scargill

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 avatar Oct 28 '21 12:10 pkitszel

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.

pkitszel avatar Oct 28 '21 12:10 pkitszel

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

scargill avatar Oct 28 '21 12:10 scargill

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

pkitszel avatar Oct 28 '21 13:10 pkitszel

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 avatar Nov 01 '21 14:11 scargill

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 avatar Nov 01 '21 14:11 scargill

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.

scargill avatar Nov 01 '21 16:11 scargill

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"
}

cocoshka avatar Nov 07 '21 22:11 cocoshka

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....

scargill avatar Nov 11 '21 05:11 scargill

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.

nkrepo avatar Nov 16 '21 19:11 nkrepo

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

ca5ua1 avatar Jan 13 '22 08:01 ca5ua1

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

visortelle avatar Jan 31 '22 22:01 visortelle

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)

mrx23dot avatar Feb 09 '22 10:02 mrx23dot

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.

Shura0 avatar Mar 28 '22 13:03 Shura0

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.

hansratzinger avatar Jun 13 '22 07:06 hansratzinger

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.

scargill avatar Jun 13 '22 11:06 scargill

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

pkitszel avatar Jul 21 '22 10:07 pkitszel

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

emidevops avatar Aug 02 '23 14:08 emidevops

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 🙏

dzalf avatar Oct 08 '23 21:10 dzalf

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

dimkasta avatar Oct 13 '23 08:10 dimkasta

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.

hgraur avatar Mar 03 '24 15:03 hgraur

@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

dimkasta avatar Mar 03 '24 20:03 dimkasta