Skip to content
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

Improve copy / paste support #1288

Open
dclong opened this issue Mar 31, 2022 · 21 comments
Open

Improve copy / paste support #1288

dclong opened this issue Mar 31, 2022 · 21 comments

Comments

@dclong
Copy link

dclong commented Mar 31, 2022

As a zellij user, I couldn't figure out how to paste text. When selecting a text in the terminal, the status bar shows "Text copied to clipboard". However, I tried various ways but couldn't manager to paste the copied text. It would a great improvement of user experience if the status bar also gives hint on the shortcuts to paste text.

@imsnif
Copy link
Member

imsnif commented Mar 31, 2022

Pasting should normally be handled by your system - so it should be the normal way you paste. Could it be that copying isn't working?

@raphCode
Copy link
Contributor

raphCode commented Apr 4, 2022

This is related to my old issue, where I indicated that a more explicit message may lead to less surprises.
tmux users expect tmux-internal copy/paste buffers which are not related with the system clipboard.

In #1018 I wrote:

I even advocate for writing "copied to the system clipboard" to make clear there are no zellij internal copy/paste buffers going on like in tmux.

Also related: #375

@imsnif
Copy link
Member

imsnif commented Apr 4, 2022

@raphCode - could you help me with some context? Are there downsides to implementing your suggestion?

@raphCode
Copy link
Contributor

raphCode commented Apr 4, 2022

I dont see any - it is literally just a string change in

CopyDestination::System => "Text copied to clipboard",

I would add the word "system" to this and the previous two lines to clarify that zellij uses the system clipboard as destination.


The other thing is that tmux offers (one? multiple?) internal paste buffer(s) like vim. These are not related to the system clipboard and allow copy/pasting text between panes/windows.

@imsnif
Copy link
Member

imsnif commented Apr 4, 2022

Cool - let's go for it. Is there a reason tmux offers these various buffers aside from historical? (I guess before it supported copying to the system clipboard)?

I don't see a use case for these - but if someone relies on them and really wants them implemented, we can look into it.

@raphCode
Copy link
Contributor

raphCode commented Apr 4, 2022

You could argue that internal paste buffers work even outside graphical environments and terminal emulators - think the linux framebuffer console in a live rescue system or using an actual hardware video terminal.

But most users are probably fine without it...

@imsnif
Copy link
Member

imsnif commented Apr 4, 2022

Fair enough - I'd be open to implementing it then if there's a need.

raphCode added a commit to raphCode/zellij that referenced this issue Apr 13, 2022
This is to avoid confusion: New users coming from tmux might expect
internal copy/paste buffers in zellij which are separate from the system
clipboard.
It may therefore be surprising where the copied text ends up and that
zellij has no dedicated "paste" functionality.

Related issues: zellij-org#1288 zellij-org#1018
tlinford pushed a commit that referenced this issue Apr 14, 2022
This is to avoid confusion: New users coming from tmux might expect
internal copy/paste buffers in zellij which are separate from the system
clipboard.
It may therefore be surprising where the copied text ends up and that
zellij has no dedicated "paste" functionality.

Related issues: #1288 #1018
@mrsarm
Copy link

mrsarm commented Oct 28, 2022

This is a big issue, part of the reason that I give up with tmux time ago and started to use Terminator. Terminator integrates well with the underlying clipboard system, and you don't need to read a bunch of documentation to be able to use something as basic as the clipboard.

I read in a mailing list about Zellij and I thought "wow, this looks cool". I think it's the reason everybody give it a shot, but we cannot exchange usability by appearance, and when a feature so important does not work as intended or is not intuitive how to use it, at least should be well documented.

If can't work like all the rest of terminals (Terminal, Terminator, Konsole...), a fix is as easy as to change the message "Text copied to clipboard" by "Text copied to clipboard. Paste it using XYZ...", a hint, based on the system configuration, because some times simple solutions works better than complex ones. Just my two cents.

@imsnif
Copy link
Member

imsnif commented Oct 28, 2022

@mrsarm - it is documented: https://zellij.dev/documentation/faq.html#copy--paste-isnt-working-how-can-i-fix-this

What you suggest isn't feasible though, unfortunately. Zellij is not a terminal emulator like terminator, it is a terminal multiplexer. It doesn't have enough knowledge about your system to tell you how to paste.

Thank you for your thoughts and suggestions. I would encourage you to use whichever tool suits you best.

@mrsarm
Copy link

mrsarm commented Oct 28, 2022

Yea I saw that, but that looks more like workarounds than how to use it. Actually my particular problem was not Zellij pasting what it's in the clipboard, it did when I press Ctrl + Shift + I, but it pasted what what I have in the system clipboard, like any normal program actually, so what did not work was the copy execution, because although Zellij show me "Text copied to clipboard", it didn't, or it does, but maybe Zellij manages the clipboard separately from the system clipboard, I don't know, but this reminds me the same issues I had with tmux, and if Zellij manage the clipboard separately from the system clipboard, that should be documented, because nobody expect that to happens in a software today I think, even vi that has some weird ways to copy and paste text is able to paste what I have in my system clipboard if I press Ctrl + Shift + I.

@imsnif
Copy link
Member

imsnif commented Oct 28, 2022

Zellij does not manage a clipboard at all. All it does is send an ANSI instruction to your terminal emulator to paste to the system clipboard. It seems like your terminal emulator does not support this. There is no feasible way for Zellij to detect this fact, so we cannot provide you feedback for this failed action.

We offer you a workaround for this though, in the documented section. I'm not sure what else you'd like us to do.

@mrsarm
Copy link

mrsarm commented Oct 28, 2022

If it's a bug, I understand that is not related with the docs, because as you said, it should works as intended. Still I don't understand why Zellij that does not allow you to click right button, open a menu and select "Copy" or something like that like all the terminals, and because I had the same experience and results with Tmux, I thought "Ok, another Tmux, that may have a weird communication with the OS that's why it so complicated to use the mouse or the clipboard".

I guess that the underlying implementation of how Tmux and Zellij works have their reasons, and it's a tradeoff you cannot avoid 🤷‍.

BTW is not the only computer where I tried Tmux and had the same issues, if you look for tmux and clipboard on Google or Stackoverflow, there is a long list of people frustrated with the same, and I see a lot of tickets in this repo also with stuff related to the clipboard, so just coincidence, or same underlying implementations that leads to the same problems, but I don't want to be rude, the project looks great, awesome UI, the way to creates and handle panes and tabs is great, and I know well how hard is to maintain OS projects that works for all. Hope these issues are solved at some point and I can give it another try, in the mean time I'll subscribe to the notifications for releases on Github waiting for the right moment. Thanks !

@imsnif
Copy link
Member

imsnif commented Oct 28, 2022

Mate - I just explained to you why this happens both for tmux and Zellij. :)
That is the technical explanation you are looking for. If it wasn't clear, I'd be happy to try and re-word it.

Zellij can't let you right click and press "Copy" because it is not a terminal, it is a terminal multiplexer*.

You are free to subscribe to the notifications and follow the project - but this is not a problem that will ever be solved. It's as you say - part of the implementation. We can't know about your clipboard.

As for being rude: while I don't think you do this intentionally, you're right now in a position where you're giving technical advice to a problem you seem not to fully understand. I get your frustration, I also wish it would "just work" - but quite a few people have devoted a lot of thought to solving this very problem. Maybe trust us that we know how big it is and have read a lot of the stackoverflow threads you mention?

*It can theoretically render a textual copy menu, but that menu would still have the same problem and the copy will fail in your case.

@cakira
Copy link

cakira commented Nov 7, 2022

Hi! I learned about Zellij yesterday and I'm giving it a try. So far, it seems great!
But an annoyance I've found is about the right mouse button. Since I'm a Windows WSL user using Windows Terminal, I usually use the right mouse button to paste and it isn't working when mouse-mode is enabled.

I experimented disabling mouse-mode, but it is very convenient so I don't want to disable it anymore.

I learned that there is a configuration copy_command: "xclip -selection clipboard", but I didn't find something like right_mouse_button_command:

Do you guys think it is a viable option to implement a configuration right_mouse_button_command: "xclip -o" so I can paste contents from clipboard?

I've just met Zellij, so I think it's impolite to create a feature request. Instead, I just want to know if my idea above is a viable one and, in case affirmative, perhaps this is a good opportunity for me to learn rust (over the next 18 months 😅) and implement this feature myself.

@imsnif
Copy link
Member

imsnif commented Nov 8, 2022

Hey @cakira - happy you are enjoying Zellij!

I think being able to bind mouse buttons is a cool idea. Once that is possible, you would definitely be able to make it work by sending xclip -o to the active pane as you suggest.

Otherwise though - have you tried using SHIFT + right-mouse-click? I think that should bypass Zellij and make your terminal do its magic.

@cakira
Copy link

cakira commented Nov 8, 2022

Wow, @imsnif !
Shift + right-mouse-click worked beautifully. 🤩
It's not as easy as just right-mouse-click, but certainly it's easier (much easier!) than learn rust and implement it myself.
Thank you!

@acook
Copy link

acook commented Feb 19, 2023

I went down a rabbit hole figuring out what support the framebuffer and linux console in general had for clipboard functionality because one of my use cases for multiplexers is emergency console access.

Long story short, there are mechanisms for buffers, but they're not typically accessed via ANSI. So either a custom integration or a Zellij-specific buffer would be required.

@jyn514
Copy link

jyn514 commented Aug 19, 2023

Zellij does not manage a clipboard at all. All it does is send an ANSI instruction to your terminal emulator to paste to the system clipboard. It seems like your terminal emulator does not support this. There is no feasible way for Zellij to detect this fact, so we cannot provide you feedback for this failed action.

Note that GNOME Terminal does not support OSC 52, so Zellij will be broken for anyone using the default terminal emulator on Ubuntu or derivatives.

(the workaround in the documentation works fine though)

@jontze
Copy link

jontze commented Jan 19, 2024

I found this issue while investigating how to make zellij "copy" work inside WSL2 as it was mentioned above (#1288 (comment)).

Just add this to your zellij config (~/.config/zellij/config.kdl):

copy_command "clip.exe"

I also opened a PR to add this to the examples of the documentation: zellij-org/zellij-org.github.io#223

@name-snrl
Copy link

Pasting should normally be handled by your system

What about SSH? I opened #3135 earlier, and I'm still hoping this will somehow be resolved to use Neovim with the OSC 52 clipboard provider in Zellij. Maybe a simple redirection of ANSI sequences?

I haven't started using any multiplexer yet and I really like Zellij with its great functionality out of the box. No need to add a bunch of plugins, it seems to do its job well out of the box and not being able to paste from the clipboard is the only thing stopping me from starting to use Zellij. So I'm very interested to know if any work is planned in this direction?

@AlpMimaroglu
Copy link

Otherwise though - have you tried using SHIFT + right-mouse-click? I think that should bypass Zellij and make your terminal do its magic.

Thank god for this message. Not being able to paste anything to zellij (in wsl) was my biggest frustration and with shift+right -click it works. This should definitely be in the copy paste faq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants