1
1
Okay, so I'm trying to solve the problem of getting the contents of a yanked register from a SSH'd session in Vim, to go to the Windows clipboard.
Here's the scenario:
- SSH into development environment
- Use Vim to edit files on server (not with local Cygwin Vim)
- Yank text
What I want to do, is use the built-in /dev/clipboard
in Cygwin to get the yanked contents so that I can start to share between the two.
There's a VimScript to do this locally (i.e., you have direct access to /dev/clipboard
):
function! Putclip(type, ...) range
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:type == 'n'
silent exe a:firstline . "," . a:lastline . "y"
elseif a:type == 'c'
silent exe a:1 . "," . a:2 . "y"
else
silent exe "normal! `<" . a:type . "`>y"
endif
"call system('putclip', @@)
"As of Cygwin 1.7.13, the /dev/clipboard device was added to provide
"access to the native Windows clipboard. It provides the added benefit
"of supporting utf-8 characters which putclip currently does not. Based
"on a tip from John Beckett, use the following:
call writefile(split(@@,"\n"), '/dev/clipboard')
let &selection = sel_save
let @@ = reg_save
endfunction
vnoremap <silent> <leader>y :call Putclip(visualmode(), 1)<CR>
nnoremap <silent> <leader>y :call Putclip('n', 1)<CR>
http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim
What I would like to do is see if there's a way I can talk to Cygwin from here, or if I can scp
the contents (or something along those lines). I can't/won't store passwords/passphrases, and ideally, I want this to be as "transparent" as possible.
Also, I'm running this through tmux, if that opens up access anywhere. Not sure if that's relevant, as I've just started playing with tmux yesterday (there might be something that I'm unaware of).
Thoughts?
Did you try X forwarding,
$ ssh -X hostname
? – romainl – 2014-06-26T07:22:46.047Unfortunately we don't have X11 installed on the server I'm Vimming on. We do have pynotify, there though. So as an exercise in nerdiness, I might have it watch a file that gets written to when a specifically mapped yank is performed, then it'll rsync the contents from there to /dev/clipboard on my local machine, which should give me access. The TCP handshake might take a second or two, but ... we'll see how it works. – Tango Bravo – 2014-06-26T14:28:08.747