From aefaff602daead79cf3cc448503e2ad0b2995bee Mon Sep 17 00:00:00 2001 From: Zaq? Wiedmann Date: Thu, 28 May 2015 13:50:07 -0700 Subject: added support for linux and windows --- plugin/system_copy.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'plugin') 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 SystemCopy :call system_copy(visualmode(),visualmode() ==# 'V' ? 1 : 0) nnoremap SystemCopy :set opfunc=system_copyg@ nnoremap SystemCopyLine :set opfunc=system_copyexe 'norm! 'v:count1.'g@_' -- cgit v1.2.3