X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=.vimrc;h=052ace0c2411344db22847dbfc9cab5f661c1183;hb=59e5881d91c20244b189a8899a02cd01bc127af3;hp=f59293420e8c60039afd64bc21176a647a3920aa;hpb=bbf4c9592895263a213089b4dd97cbe1f82f3f9a;p=dotfiles.git diff --git a/.vimrc b/.vimrc index f592934..052ace0 100644 --- a/.vimrc +++ b/.vimrc @@ -586,26 +586,26 @@ endif " From Tip 212: " http://vim.wikia.com/wiki/Setting_file_attributes_without_reloading_a_buffer -function! SetExecutableBit(x) - if !executable('chmod') - return - endif - checktime - let fname = expand("%:p") - let fx = executable(fname) - execute "au FileChangedShell " . fname . " :echo" - if a:x && !fx - !chmod a+x % - elseif !a:x && fx - !chmod a-x % - endif - if v:shell_error - echoerr 'Error running chmod: ' . v:shell_error - endif - checktime - execute "au! FileChangedShell " . fname -endfunction -command! Xbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif +if executable('chmod') + function! SetExecutableBit(x) + checktime + let fx = executable(expand("%:p")) + execute "au FileChangedShell call _BufChangedCB()" + if a:x && !fx + !chmod a+x % + elseif !a:x && fx + !chmod a-x % + endif + if v:shell_error + echoerr 'Error running chmod: ' . v:shell_error + endif + checktime + endfunction + function! _BufChangedCB() + execute "au! FileChangedShell " + endfunction + command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif +endif " ----------