micro icon indicating copy to clipboard operation
micro copied to clipboard

Differing copy-paste mechanics between tmux and non-tmux

Open ryan-caesar-ramos opened this issue 1 year ago • 3 comments

Description of the problem or steps to reproduce

Could someone help me understand which of these is the expected behavior?

When I ssh into my workstation, I can copy something from outside micro and paste it within micro using Cmd+V, Ctrl+V, and Ctrl+Shift+V. However when I try to copy something from within micro with Ctrl+C (which shows the "Copied selection" message at the bottom), pasting results in the text previously copied from outside micro. Ctrl+Shift+C and Cmd+C don't work either (they don't even show the "Copied selection" message).

So in summary

non-tmux

  • Ctrl+V: pastes last thing copied from outside micro
  • Cmd+V: pastes last thing copied from outside micro
  • Ctrl+Shift+V: pastes last thing copied from outside micro
  • Ctrl+C: shows "Copied selection" message but can't paste what was just copied
  • Cmd+C: no "Copied selection" message
  • Ctrl+Shift+C: no "Copied selection" message

When I ssh into my workstation and enter a tmux session, I can copy and paste within the file using Ctrl+C and Ctrl+V. Cmd+V and Ctrl+Shift+V paste whatever the previous non-micro thing I copied was. However I cannot copy something from within micro and paste the contents outside it.

Again in summary that's

tmux

  • Ctrl+V: pastes last thing copied from inside micro
  • Cmd+V: pastes last thing copied from outside micro
  • Ctrl+Shift+V: pastes last thing copied from outside micro
  • Ctrl+C: copies text from within file
  • Cmd+C: no "Copied selection" message
  • Ctrl+Shift+C: no "Copied selection" message

Is it possible to configure things so that I can copy from within micro and paste the contents both within and outside micro? And to copy something from outside micro and paste it within micro? Regardless of whether I'm doing this over ssh and/or tmux? I already set clipboard to terminal in my micro settings.json and configured the clipboard_control part of my kitty config to read_primary and read-clipboard.

Specifications

Commit hash: c2cebaa3 OS: MacOS Sonoma 14.3.1 ssh-ing into Ubuntu 22.04.4 LTS Terminal: kitty 0.33.1

ryan-caesar-ramos avatar May 25 '24 08:05 ryan-caesar-ramos

I think it is expected that the clipboard was not set with the text copied in micro when Ctrl+C is pressed because write-clipboard or write-primary were not also specified in clipboard_control in kitty configuration.

Cmd+C and Cmd+V are the same with Ctrl+Shift+C and Ctrl+Shift+V but they are handled in kitty. Ctrl+C and Ctrl+V are handled in micro. There is no event received in micro when text is copied using Cmd+C and Ctrl+Shift+C so there is no message when those shortcuts are pressed.

I was looking at this page but no-append would have to be added in clipboard_control in kitty configuration when using clipboard in tmux: https://github.com/tmux/tmux/wiki/Clipboard#terminal-support---kitty I have not used tmux before but I think text copied when pressing Ctrl+C in micro in tmux can also be pasted in other programs when set-clipboard (server option) is set as on in ~/.tmux.conf like this:

set -s set-clipboard on

I do not know if it is a bug but I was not able to retrieve the text in the clipboard like how it is done when pressing Ctrl+V in micro when I was testing using tmux 3.3a and kitty 0.19.3.

niten94 avatar Jun 04 '24 13:06 niten94

Sorry for the late reply!

So far I have clipboard_control read-primary read-clipboard write-clipboard write-primary no_append in my kitty conf file, and I have

set-option -s set-clipboard external
set -as terminal-features, ',rxvt-unicode-256color:clipboard

in my tmux conf file, as recommended here. Despite this, I have the same issues.

I also tried set-option -s set-clipboard on and set -s copy-command 'xsel -i', still no luck.

Anyone have any ideas as to what's going on?

ryan-caesar-ramos avatar Jun 26 '24 07:06 ryan-caesar-ramos

The comma after terminal-features has to be removed and apostrophe has to be added at the end in the 2nd command like this: set -as terminal-features ',rxvt-unicode-256color:clipboard'

I do not think xsel can usually be used on Mac and ssh sessions.

niten94 avatar Jul 02 '24 10:07 niten94