Skip to content

Commit

Permalink
Use sudo -A on local Neovim
Browse files Browse the repository at this point in the history
References #45
  • Loading branch information
tpope committed Mar 17, 2018
1 parent b62f7d4 commit 0971b4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin/eunuch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ endfunction

function! s:SilentSudoCmd(editor) abort
let cmd = 'env SUDO_EDITOR=' . a:editor . ' VISUAL=' . a:editor . ' sudo -e'
if !has('gui_running')
let local_nvim = has('nvim') && len($DISPLAY . $SECURITYSESSIONID)
if !has('gui_running') && !local_nvim
return ['silent', cmd]
elseif !empty($SUDO_ASKPASS) ||
\ filereadable('/etc/sudo.conf') &&
\ len(filter(readfile('/etc/sudo.conf', 50), 'v:val =~# "^Path askpass "'))
return ['silent', cmd . ' -A']
else
return ['', cmd]
return [local_nvim ? 'silent' : '', cmd]
endfunction

function! s:SudoSetup(file) abort
Expand Down

0 comments on commit 0971b4c

Please sign in to comment.