OSC52 clipboard yanks

This commit is contained in:
Christian Nieves
2023-02-13 12:31:47 -06:00
parent 189570685b
commit 84aa6e8933
7 changed files with 117 additions and 47 deletions

View File

@ -29,8 +29,8 @@ vmap <leader>v c<ESC>"+p<ESC>
imap <leader>v <ESC>"+pa
" Copy to OS clipboard
vnoremap <leader>y "yy <Bar> :call system('xclip', @y)<CR>
map <leader>y "yy <Bar> :call system('xclip', @y)<CR>
" vnoremap <leader>y "yy <Bar> :call system('xclip', @y)<CR>
" map <leader>y "yy <Bar> :call system('xclip', @y)<CR>
" --------- WINDOW/PANE MAPPINGS ---------
map <leader>wr <C-W>r
@ -123,3 +123,25 @@ function! <SID>SynStack()
endfunc
nnoremap <leader>s :SaveSession<CR>
" copy to attached terminal using the yank(1) script:
" https://github.com/sunaku/home/blob/master/bin/yank
function! Yank(text) abort
let escape = system('yank', a:text)
if v:shell_error
echoerr escape
else
call writefile([escape], '/dev/tty', 'b')
endif
endfunction
noremap <silent> <Leader>y y:<C-U>call Yank(@0)<CR>
" automatically run yank(1) whenever yanking in Vim
" (this snippet was contributed by Larry Sanderson)
function! CopyYank() abort
call Yank(join(v:event.regcontents, "\n"))
endfunction
" autocmd TextYankPost * call CopyYank()
noremap <leader>y call CopyYank()
vnoremap <leader>y call CopyYank()