if executable('chmod')
function! SetExecutableBit(x)
checktime
+ " Avoid 'Reload Y/N?' question
+ autocmd FileChangedShell <buffer> call _BufChangedCB()
let fx = executable(expand("%:p"))
- execute "au FileChangedShell <buffer> call _BufChangedCB()"
if a:x && !fx
!chmod a+x %
elseif !a:x && fx
checktime
endfunction
function! _BufChangedCB()
- execute "au! FileChangedShell <buffer>"
+ autocmd! FileChangedShell <buffer>
endfunction
command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif
endif