Closed unphased closed 1 year ago
I guess I'm realizing there's little need for me to keep vim sticking to my "standardized" pbcopy clipboard manipulator script. Elegant though it may be sharing that code, all the creature comforts specific to vim which youve provided in this plugin are worth something, and I think the behavior of getting the buffer into the client machine clipboard is always what I want to do with essentially zero exceptions, there's actually no reason for me to follow that premise. And I will be able to eliminate the shenanigans that I did to allow me to adequately pass a visual-selected buffer or individual lines into my pbcopy script (which is already a bit gnarly).
Still, would love to learn why my approach doesnt work in nvim when it actually works in vim.
I know that Vim and Neovim have different behaviors when you execute a shell command from inside them so it's probably related to that. How exactly do you invoke pbcopy
from inside Vim and Neovim?
One test I did was to open :Terminal and execute the shell script.
Sorry I'm a bit all over the place with this topic. I am gonna be totally honest with you -- i read what i wrote again and I don't really think I understand the issue either. Let me hijack my own topic, then:
What I can report right now is that on my macbook (I was testing on my Linux box earlier...), I had to set let g:oscyank_term = 'default'
in my vimrc to make this work from inside tmux.
It looks like the problem is that get_OSC52_tmux
doesn't work for me. I am not an expert on this, but I think I understand what's going on. This
return "\ePtmux;\e\e]52;c;" . b64 . "\x07\e\\"
Is to leverage the
allow-passthrough [on | off]
Allow programs in the pane to bypass tmux using a terminal escape
sequence (\ePtmux;...\e\\).
feature of tmux. But most people like myself don't have this option enabled, and furthermore the regular OSC52 clipboard ansi escape behavior is handled properly transparently by tmux.
So I suggest let g:oscyank_term = 'default'
to be the default behavior of the plugin.
I have a hunch this isn't done for some security reason?
I also suggest this plugin by default uses "default mode" inside tmux, instead of using the passthrough.
Basically, there are 2 ways to make this plugin work in tmux:
set-clipboard
in tmux.allow-passthrough
in tmux.(2) has security concerns, because it allows ALL escape sequences to pass through tmux. (1) is cleaner because it avoids an extra mode -- the extra mode can be removed in theory if we get rid of (2) completely.
I've deeply refactored the code, and the default mode + setting set-clipboard
is now the default behavior. You can still use the second mode, just check :h oscyank-tmux
.
So I've already done a lot of consolidating clipboard behavior for my vim/terminal/tmux workflow. I use this script:
and I call into this from tmux, and I call it from vim, and i can call it on the zsh terminal, etc., it's very nice because it's a unified implementation.
I really like the way you've gotten the OSC yank working in this plugin for vim and nvim. The last line in my pbcopy script here is inspired by your plugin here, and was recently added to this script.
set-clipboard
option was already successfully tunneling any tmux copy-mode selections out into the client machine clipboard via terminal emulator internally via OSC52. I've enjoyed this for a while. I also call mypbcopy
viabind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy" \;
which served to also assign my fallback clipboard file and the server's system clipboard as well if possible. Now that it also does the OSC52 it's a little redundant but that's okay.pbcopy
from vim/nvim. Now that I've added my bash implementation of OSC52 clipboard manipulation, this works in vim but does not work in neovim.Curious if you might have insight into why it doesn't work for me in neovim. As you can see my script just emits whatever output needs to go out to the terminal unmolested, and vim appears to succeed with that, but neovim does not. I'm curious if you had to do anything to work around this.