diff options
Diffstat (limited to 'runtime/autoload/provider/clipboard.vim')
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index f63ad5730b..b8baaa8c64 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -22,14 +22,23 @@ function! s:try_cmd(cmd, ...) let argv = split(a:cmd, " ") let out = a:0 ? systemlist(argv, a:1, 1) : systemlist(argv, [''], 1) if v:shell_error - echohl WarningMsg - echo "clipboard: error: ".(len(out) ? out[0] : '') - echohl None + if !exists('s:did_error_try_cmd') + echohl WarningMsg + echomsg "clipboard: error: ".(len(out) ? out[0] : '') + echohl None + let s:did_error_try_cmd = 1 + endif return 0 endif return out endfunction +" Returns TRUE if `cmd` exits with success, else FALSE. +function! s:cmd_ok(cmd) + call system(a:cmd) + return v:shell_error == 0 +endfunction + let s:cache_enabled = 1 let s:err = '' @@ -45,7 +54,7 @@ function! provider#clipboard#Executable() abort let s:paste['*'] = s:paste['+'] let s:cache_enabled = 0 return 'pbcopy' - elseif exists('$DISPLAY') && executable('xsel') + elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b') let s:copy['+'] = 'xsel --nodetach -i -b' let s:paste['+'] = 'xsel -o -b' let s:copy['*'] = 'xsel --nodetach -i -p' |