Skip to content

Instantly share code, notes, and snippets.

@violetyk
Created November 13, 2013 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save violetyk/7444938 to your computer and use it in GitHub Desktop.
Save violetyk/7444938 to your computer and use it in GitHub Desktop.
function! s:Paste64Copy() range
let l:tmp = @@
silent normal gvy
let l:selected = @@
let b64 = webapi#base64#b64encode(l:selected)
if $TMUX != ""
"tmuxのとき
let cmd = printf('printf "\x1bPtmux;\x1b\x1b]52;;%s\x1b\x1b\\\\\x1b\\" > /dev/tty', b64)
" call system('printf "\x1bPtmux;\x1b\x1b]52;;%s\x1b\x1b\\\\\x1b\\" > /dev/tty')
elseif $TERM == "screen"
"GNU Screenのとき
let cmd = printf('printf "\x1bP\x1b]52;;%s\x07\x1b\\" > /dev/tty', b64)
" call system('printf "\x1bP\x1b]52;;%s\x07\x1b\\" `echo -en "' . l:escaped . '" | base64` > /dev/tty')
else
let cmd = printf('printf "\x1b]52;;%s\x1b\\" > /dev/tty', b64)
endif
call system(cmd)
redraw!
let @@ = l:tmp
endfunction
command! -range Paste64Copy :call s:Paste64Copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment