Remote tmux over ssh copy/paste/clipboard in konsole

Hi, I was wondering if someone could help me with konsole. I want to perform the following workflow:

  1. start the terminal (konsole)
  2. ssh into a remote machine
  3. start tmux on the remote machine
  4. copy a text selection from the tmux session on the remote machine
  5. paste onto the local machine somewhere (e.g. into kate or some other kde app)

The local clipboard doesn’t get updated when I do a tmux copy on the remote. Many terminal emulators like iterm2, kitty, wezterm seem to support this workflow. Is there some setting I can change to make it work in konsole? If not, is this a feature you’d consider developing? If not, do you think it’d be hard to implement. I could try but I have no domain specific knowledge in this regard.

Your responses are much appreciated. Thank you.

I’m not super knowledgeable about tmux, but just a clarifying question based on how you laid out what you’re doing - does copying out of konsole and pasting into a GUI app on your system work when it’s not from a remote tmux? And what steps are you taking to copy that text?

Yes, I can start a local tmux session and select text within it and copy and paste to kate or another terminal window. I can select text with the mouse, then go to a kate window and ctrl+v into that window.

I regularily do exactly that and it works without a problem here. Can you mouse select the text in the remote Konsole window? You just have to use Shift-Ctrl-c for copying it in Konsole.

One thing I’m not sure about: I know tmux can be configured to accept mouse actions via the terminal window, which I’ve never tried. I’m not sure what happens if you do that and activate “Allow Mouse Tracking” in Konsole’s “View” menu.

So let me clarify a little. I have tmux set up with mouse mode enabled. The setup is that there are two tmux panes with a vertical split so that there are two panes side by side. With mouse mode enabled tmux correctly selects the text in one side and copies and pastes that when using the other terminals. Konsole just doesn’t receive this buffer from the tmux mouse mode copy.

ctrl+shift+c will copy the remote buffer but if tmux has a split pane in the middle, it will copy across the two panes and produce an unusable paste output as the text from the two panes is interleaved.

Gotcha. This I have never done but I found this and hope it might help you?

It did help me but not directly. After a long rabbit hole from that post I believe the feature that is missing is ANSI OSC-52. It looks like there’s been an 8 year thread at bugs dot kde dot org bug id=372116 (I can’t paste links here apparently) and maybe a month ago it got merged. However, it’ll be in kde gear 24.12 but I have 24.08 of kde gear. My interpretation of that thread could be wrong though. Seems silly it took 8 years. Maybe I’ll try building it from source.

I can confirm, I just built the latest source of konsole and it works because ANSI OSC-52 was added as of a month ago. It just hasn’t made it to a release yet.

Now that’s awesome - glad to hear it! 8 years is not silly. The KDE folks have as little spare time as anyone so they have to prioritize just like anyone else.

1 Like