I have vim open inside tmux inside an ssh session. How can I make vim use my laptop\'s system clipboard as the default copy paste? The default set clipboard=unamed
Clipboard integration feature (PASTE64/OSC52) is helpful if your terminal emulator supports it. For example, iTerm2 supports it (I am not sure about Ubuntu).
Add this function to your "remote" .vimrc.
yank something and run :OscCopy. It works even it is inside tmux session.
function! OscCopy()
let encodedText=@"
let encodedText=substitute(encodedText, '\', '\\\\', "g")
let encodedText=substitute(encodedText, "'", "'\\\\''", "g")
let executeCmd="echo -n '".encodedText."' | base64 | tr -d '\\n'"
let encodedText=system(executeCmd)
if $TMUX != ""
"tmux
let executeCmd='echo -en "\x1bPtmux;\x1b\x1b]52;;'.encodedText.'\x1b\x1b\\\\\x1b\\" > /dev/tty'
else
let executeCmd='echo -en "\x1b]52;;'.encodedText.'\x1b\\" > /dev/tty'
endif
call system(executeCmd)
redraw!
endfunction
command! OscCopy :call OscCopy()
gist