ojroques / vim-oscyank

A Vim plugin to copy text through SSH with OSC52
BSD 2-Clause "Simplified" License
629 stars 39 forks source link

Oscyank also yank the content of previous yank #5

Closed jiangtianli91 closed 3 years ago

jiangtianli91 commented 3 years ago

I am yanking texts from vim in a tmux session in a remote machine (Terminal emulator is Kitty)

Suppose I have two lines:

This is good
This is also good

When I first oscyank This is good It works. However, when I oscyank This is also good the content I got is two lines together, This is good This is also good

ojroques commented 3 years ago

Hello!

This is because Kitty implements its own slightly different version of the OSC52 protocol: see here. By default it appends any yanked lines to the previous content of the clipboard. To disable this behavior add no-append to the clipboard_control option of kitty: see doc here.

I thought I had taken care of this behavior in the plugin but it seems not, I'll take a look.

EDIT: The kitty workaround implemented in the plugin works fine on my machine so it's probably the terminal detection that fails on your side. You can add this to your .vimrc if you don't want to touch your kitty config:

let g:oscyank_term = 'kitty'
ojroques commented 3 years ago

I'm closing this issue. Feel free to re-open it if your problem persists.

SimplyKnownAsG commented 3 years ago

how was this solved? I'm using kitty locally, and tmux on a remote machine. I noticed the note about kitty's OSC52 implementation.

When I set let g:oscyank_term = 'kitty', the note about how many bytes were copied appears, but it doesn't actually end up in the paste board (OSX). If I do not assign g:oscyank_term, then it appends.

ojroques commented 3 years ago

Tmux is also a special case that must be handled on its own. I suspect that the combination of kitty + tmux is what causes the issue.

Try removing let g:oscyank_term from your Vim config and instead put clipboard_control no-append in your kitty config in ~/.config/kitty/kitty.conf.

SimplyKnownAsG commented 3 years ago

Most excellent. I should have looked into that myself. This could nearly have been a RTFM response. Thanks for being so helpful! clibpoard_control no-append overrides the default, so the actual solution is for my case of using tmux on a remote machine and kitty locally:

vimrc: leave let g:oscyank_term to do it's default kitty.conf: clipboard_control no-append write-clipboard write-primary