Created
July 14, 2015 15:52
-
-
Save koturn/49fb1429d4c722e932a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if executable('sudo') | |
function! s:save_as_root(is_bang, filename) | |
if a:filename ==# '' | |
let l:filename = '%' | |
else | |
let l:filename = a:filename | |
endif | |
execute 'write' . a:is_bang ' !sudo tee > /dev/null ' . l:filename | |
endfunction | |
else | |
function! s:save_as_root(is_bang, filename) | |
echoerr 'sudo is not supported in this environment.' | |
endfunction | |
endif | |
command! -bar -bang -nargs=? -complete=file Write call s:save_as_root('<bang>', <q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment