First off, I'd like to note that the implication that you cannot use the system clipboard from terminal Vim is false. I use it all the time. (This implication isn't in your question, but it is in the comments.) So if I were in your situation, I would simply install a different Vim package that does include the
That said, here's a proof of concept which uses a tmux buffer and the
system() function to provide (just) the functionality you asked for:
nnoremap <silent> yy yy:call system('tmux set-buffer -b vim ' . shellescape(@"))<CR>
nnoremap <silent> p :let @" = system('tmux show-buffer -b vim')<cr>p$x
These mappings use the standard
p commands to perform the actual yank and put, but include system calls to save the contents of the unnamed register in a tmux buffer after yanking and load the buffer contents back into the unnamed register before putting.
N.B. If I were using this in earnest, I would extend this and tidy it up a fair bit (for instance, with these mappings you can now only
p things that you have previously yanked with
yy: the easiest way around this is use
<leader>p as the triggers), but this shows the basic functionality.
Here's another version which instead uses tmux's
send-keys to directly copy over the contents of the unnamed register when you yank, which in some ways is cleaner, and avoids the problem with the
p mapping described above:
nnoremap <silent> yy yy:call system('tmux send-keys -t 1 ":let @\" = \"' . shellescape(@")[1:-2] . '\"' . "\r\"")<CR>
Currently this is losing the newline at the end of the yanked line: it could probably be tidied up not to do so.