zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Copying text to the system clipboard doesnt work

Open gzsombor opened this issue 1 year ago • 17 comments

2. Issues with the Zellij UI / behavior

Issue description

Unable to copy text selection / url from Zellij doesn't work - even though zellij reports, that 'Text copied to system clipboard'. However, I can't paste the text / url. I've tried to run Zellij in KDE's Konsole, xterm, and wezterm, and it behaves exactly the same

Minimal reproduction

  1. Open ZelliJ
  2. Select a text with the mouse
  3. Notice, that there is a 'Text copied to system clipboard' displayed on the bottom
  4. Neither middle button click, nor the other 'paste' keyboard shortcuts could trigger paste

Other relevant information

zellij 0.39.2

konsole 21.12.3 wezterm 20230712-072601-f4abf8fd XTerm(372)

gzsombor avatar Dec 18 '23 16:12 gzsombor

I had the same issue with wezterm, I configured wezterm to allow pasting to and from wezterm to system clipboard. Now it works fine I can copy to and from system clipboard to wezterm and vice versa. I think the issue is not with zellij, it is with the terminal emulator. As per my knowledge these terminal emulators don't have default config for copy and paste except bash.

raj-hegde avatar Dec 19 '23 19:12 raj-hegde

I've just run into this and I'm at a loss as to what changed on my end to trigger it. I switched machines and use Arch so there's a lot.

What may provide some indication as to what is going wrong is that I can manage to get text copied by Zellij to come out. Just not in a terminal or gVim. Both Chrome and Firefox via Ctrl-V will gladly paste whatever Zellij copies. xclip cannot find this text in any of the 3 selection buffers so I'm lost as to where it's getting stashed. Using xclip in copy_command will also work, but my standard usage has zero X forwarding between my box and where I'm running Zellij.

Please fix this, the workflow without proper copy-paste is hellish.

X.Org 1.21.1.11 zellij 0.39.2 kitty 0.33.0 xfce4-terminal 1.1.3 (4.18) Chrome 122.0.6261.128 Firefox 124.0

alaricljs avatar Mar 19 '24 19:03 alaricljs

Circling back around, reading #1288 helped figure out the fix. I do want to call out that sometimes under very unpredictable circumstances copy/paste in Zellij does work with my current pre-fixed environment. It definitely involves both mouse and Zellij pane focus but I haven't gotten a consistent recipe.

Now on to my fix -- autocutsel -selection PRIMARY syncs things such that mouse select inside Zellij can then paste wherever via middle click. This only changes the behavior of copy/paste while running Zellij. xfce4-terminal and kitty both do fine without it when not running Zellij.

alaricljs avatar Mar 19 '24 20:03 alaricljs

Same happens to me in Konsole terminal. Works fine in alacritty

b-m-f avatar May 21 '24 16:05 b-m-f

Inside fish shell copy with mouse not working

Even not with keystrokes

osevan avatar Aug 01 '24 13:08 osevan

Wayland kde plasma im using.

Keystrokes not working, i tryed every config 3 options wl-copy too

osevan avatar Aug 01 '24 21:08 osevan

same like @osevan void linux kde plasma yakuake copy is not working from zellij

noor-tg avatar Sep 15 '24 20:09 noor-tg

same with gnome-terminal default ubuntu terminal

to fix it you can follow this

Some terminals don't support the the OSC 52 signal, which is the method Zellij uses by default to copy text to the clipboard. To get around this, you can either switch to a supported terminal (eg. Alacritty or xterm) or configure Zellij to use an external utility when copy pasting (eg. xclip, wl-copy or pbcopy).

To do the latter, add one of the following to your Zellij Config:

copy_command: "xclip -selection clipboard" # x11
copy_command: "wl-copy"                    # wayland
copy_command: "pbcopy"                     # osx

Note that the only method that works when connecting to a remote Zellij session (eg. through SSH) is OSC 52. If you require this functionality, please consider using a terminal that supports it.

then make sure to kill all zellij sessions and restart your terminal

marawanxmamdouh avatar Sep 20 '24 16:09 marawanxmamdouh

@marawanxmamdouh thank you for the tip.

noor-tg avatar Sep 26 '24 13:09 noor-tg

Ubuntu 24.04 with wayland.

Install xclip sudo apt install xclip

Add in config.kdl copy_command "xclip -selection clipboard"

Kill session zellij zellij delete-all-sessions

Everthing working!

joaotux avatar Nov 09 '24 17:11 joaotux

@joaotux if you're using wayland why are you using xclip instead of wl-copy?

eric-hansen avatar Nov 12 '24 09:11 eric-hansen

@eric-hansen wl-copy doesn't work for me.

joaotux avatar Nov 12 '24 13:11 joaotux

Wl-copy didn't work for me either in fedora

Thanks for the alternative @joaotux

tomhoq avatar Feb 04 '25 09:02 tomhoq

using xclip did it for me copy_command "xclip -selection clipboard" // x11

mapsgeek avatar Feb 11 '25 01:02 mapsgeek

This changes work for me (copy and paste)

Install xclip if it's not already installed: sudo apt install xclip

Navigate to this file cat .config/zellij/config.kdl

Uncomment the following line copy_command "xclip -selection clipboard"

satyakam-vyrill avatar Apr 04 '25 09:04 satyakam-vyrill

Had same issue when using zellij via ssh in Tabby terminal, and only setting mouse_mode to false in .config/zellij/config.kdl resolved it, unfortunately killing the mouse scroll functionality. If anyone has a better solution, please let me know.

akaia-shadowfox avatar Apr 27 '25 18:04 akaia-shadowfox

fixing this on osx should definitely be more obvious upon initial setup.

Jac0xb avatar May 01 '25 17:05 Jac0xb

I installed Zellij today for the first time on macOS Sequoia in Terminal.app and although it says it copied the text to the system clipboard, it didn't. iTerm2 and Ghostty worked fine.

clarkey avatar Jul 12 '25 09:07 clarkey

For those who would like to keep mouse_mode to true, you can press shift while selecting text. This allows the terminal to handle the selection instead of Zellij.

mouse_mode true
copy_command "xclip -selection clipboard" // x11

Working through an ssh connection with Tabby.

panaxging avatar Aug 14 '25 11:08 panaxging

For those who would like to keep mouse_mode to true, you can press shift while selecting text. This allows the terminal to handle the selection instead of Zellij.

mouse_mode true
copy_command "xclip -selection clipboard" // x11

Working through an ssh connection with Tabby.

The copying part of this works for me (using Ubuntu and zellij inside standard gnome-terminal), but I cannot past with middle-click on the mouse in the zellij session (and that works in all other applications, even with text copied into clipboard by zellij).

So, to paste anything back into zellij, I have to shift+mark and then SHIFT+CTRL+V to paste (if I've set zellij up to copy to system clipboard). I would like to be able to paste by middle-click (from primary clipboard instead), as I can do - also with the text copied by zellij - into any other window.

andersgb1 avatar Oct 10 '25 09:10 andersgb1

I'm on Debian 13 and I only use xterm. When I added this to my .Xresources:

XTerm*allowWindowOps: true

then changed copy_clipboard "primary" in $HOME/.config/zellij/config.kdl and now I have proper copy-and-paste support. Leaving this here in case it helps someone else.

jjmcdn avatar Nov 25 '25 18:11 jjmcdn