mprocs icon indicating copy to clipboard operation
mprocs copied to clipboard

[Feature Request] Select and copy text

Open arifd opened this issue 2 years ago • 10 comments

Hey,

so happy to report that we've now started using mprocs, after the scroll wheel update which is great. thank you!

Links are clickable which is great, but would it be possible to be able to select and copy text from the terminal, like you can otherwise? (Also change the pointer to the text icon)

arifd avatar Jul 08 '22 22:07 arifd

Hi. Thank you, happy to hear that mprocs is working for you.

This feature certainly should be included into mprocs. I'm thinking to implement it similar to tmux copy mode.

What do you mean by "Also change the pointer to the text icon"?

pvolok avatar Jul 09 '22 04:07 pvolok

I use mprocs at work, and this is the only feature that is missing to me!

Alex141642 avatar Jul 09 '22 09:07 Alex141642

Hey @pvolok ! Thanks for the new version! I tried the copy function, but it seems that binding key 'c' doesn't copy the selected text..

I was able to select text with my mouse, pressing key 'c' and try to paste it. Is there something i'm missing? The command i tried: mprocs 'ls -la'

Alex141642 avatar Jul 22 '22 17:07 Alex141642

@Alex141642 Which terminal are you using? And are you using tmux or screen? The first implementation is using OSC 52 terminal escape sequence, which might be disabled or not supported by terminal app or multiplexer.

For tmux it is disabled by default: https://github.com/pvolok/mprocs#copying-doesnt-work-in-tmux

I will probably have to add other ways to set clipboard content.

pvolok avatar Jul 23 '22 03:07 pvolok

I'm using Terminator/Konsole with Fish !

Alex141642 avatar Jul 23 '22 06:07 Alex141642

Not being able to mark text for copy by dragging with left mouse button pressed, or to paste text marked or copied elsewhere by pressing the middle mouse button, unfortunately makes this a show stopper for Linux terminal users.

Tried in Terminator and in good old xterm.

Too bad as this is otherwise a tool that would seem to otherwise be a tool perfectly fitting my "manage vagrant VM groups" needs ... :(

hartmut-mariadb avatar Jul 25 '22 15:07 hartmut-mariadb

It is actually very good!

Alex141642 avatar Jul 25 '22 18:07 Alex141642

It would be very good if it weren't for this show stopper. What's it good for to be able to switch between different tools output when not being able to seamlessly copy and paste?

Or are you telling me that it's good that this is not possible?

hartmut-mariadb avatar Jul 25 '22 18:07 hartmut-mariadb

@hartmut-mariadb Selecting with mouse works. The problem is that not all terminals support copying via terminal escape codes. But I plan to add copying with other means for those terminals.

pvolok avatar Jul 26 '22 00:07 pvolok

Selecting with the mouse does not work for me, I so far tried terminator, xfce4-terminal and good old xterm

Pasting a selection from another terminal with the middle mouse button works in xfce4-terminal, does not work in good old xterm, and when using terminator it turned out that a double-middle-click works.

hartmut-mariadb avatar Jul 26 '22 00:07 hartmut-mariadb

I just released mprocs 0.6.3 with a more robust copy implementation. I hope it works for everyone. I will close this issue, please open new issues if you face any problems with the new implementation.

pvolok avatar Aug 19 '22 22:08 pvolok

Hi @pvolok, this looks great! But unfortunately, both me and my colleague are unable to copy. there is nothing in the clipboard.

me: Ubuntu 21.04 colleague: Debian GNU/Linux 11 (bullseye)

arifd avatar Aug 23 '22 12:08 arifd

@arifd On Linux we check which copy tool is available from this list:

  • wl-copy
  • xclip
  • xsel
  • termux-clipboard-set
  • tmux

If none of those tools exist in $PATH, then a terminal escape sequence OSC52 is issued (which hopefully will be picked up by your terminal app).

Can you please provide the following:

  • terminal app
  • x11 or wayland
  • tmux?

pvolok avatar Aug 23 '22 20:08 pvolok

Correct, none of the above commands are installed. In my case:

  • terminal app: VS Code (1.69.0)
  • x11 or wayland: x11,
  • tmux?: not installedtmux

arifd avatar Aug 23 '22 20:08 arifd

@arifd To copy text on x11 mprocs tries to use xsel or xclip commands. I guess that you don't have either of those available. Can you try to install either of those from your distro repos and check if mprocs can copy text?

pvolok avatar Aug 26 '22 19:08 pvolok

Yup installing xsel solved it. thanks.

Perhaps this package https://crates.io/crates/clipboard/0.5.0 which also uses clipboard-win would give you cross compatibility out of the box?

arifd avatar Aug 28 '22 14:08 arifd

@arifd I used that crate and tried others similar. But they all segfault on linux without x11. So for now I just copied the way neovim does copying. I think it's possible to use x11-clipboard crate to copy directly through x11 api, but I'd prefer not to deal with it right now.

pvolok avatar Aug 29 '22 13:08 pvolok