Skip to content

Instantly share code, notes, and snippets.

@ljjjustin
Last active December 25, 2022 07:26
Show Gist options
  • Save ljjjustin/635f520abe4cb2861b3962d0df544295 to your computer and use it in GitHub Desktop.
Save ljjjustin/635f520abe4cb2861b3962d0df544295 to your computer and use it in GitHub Desktop.
use channel to send yanked content
function! s:send2ssh()
if has("nvim")
let ch = sockconnect('tcp', '127.0.0.1:22222')
if ch == 0
echomsg "failed to connect 127.0.0.1:22222"
endif
call chansend(ch, getreg('"'))
call chanclose(ch)
else
let ch = ch_open('127.0.0.1:22222')
if ch_status(ch) != "open"
echomsg "ssh channel is not open, status = " .. ch_status(ch)
endif
call ch_sendraw(ch, getreg('"'))
call ch_close(ch)
endif
endfunction
augroup pbcopy
au!
au TextYankPost * if v:event.operator ==# 'y' | call s:send2net() | endif
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment