aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/system_copy.vim
diff options
context:
space:
mode:
authorZaq? Wiedmann2015-05-28 13:50:07 -0700
committerZaq? Wiedmann2015-05-28 15:35:26 -0700
commitaefaff602daead79cf3cc448503e2ad0b2995bee (patch)
tree6cd0717f0ecb343f7b88221249bcae321f40bb13 /plugin/system_copy.vim
parent815bdef7c0bb6eab62c48d34b85b4082f0566a5d (diff)
downloadvim-system-copy-aefaff602daead79cf3cc448503e2ad0b2995bee.tar.bz2
added support for linux and windows
Diffstat (limited to 'plugin/system_copy.vim')
-rw-r--r--plugin/system_copy.vim13
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>