diff options
Diffstat (limited to 'plugin/system_copy.vim')
| -rw-r--r-- | plugin/system_copy.vim | 13 | 
1 files changed, 12 insertions, 1 deletions
| diff --git a/plugin/system_copy.vim b/plugin/system_copy.vim index 71a67f1..80a58f0 100644 --- a/plugin/system_copy.vim +++ b/plugin/system_copy.vim @@ -18,7 +18,7 @@ function! s:system_copy(type, ...) abort    else      silent exe "normal! `[v`]y"    endif -  silent call system('pbcopy', getreg('@')) +  silent call system(s:CopyCommandForCurrentOS(), getreg('@'))    echohl String | echon 'Copied to system clipboard via: ' . mode | echohl None  endfunction @@ -33,6 +33,17 @@ function! s:resolve_mode(type, arg)    endif  endfunction +function! s:CopyCommandForCurrentOS() +  let os = substitute(system('uname'), '\n', '', '') +  if has("gui_mac") || os == 'Darwin' +    return 'pbcopy' +  elseif has("gui_win32") +    return 'clip' +  else +    return 'xsel --clipboard --input' +  endif +endfunction +  xnoremap <silent> <Plug>SystemCopy :<C-U>call <SID>system_copy(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR>  nnoremap <silent> <Plug>SystemCopy :<C-U>set opfunc=<SID>system_copy<CR>g@  nnoremap <silent> <Plug>SystemCopyLine :<C-U>set opfunc=<SID>system_copy<Bar>exe 'norm! 'v:count1.'g@_'<CR> | 
