set autoread automatically give executable permissions if file begins

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set autoread
" automatically give executable permissions if file begins with #!
function! ModeChange()
if getline(1) =~ "^#!"
silent !chmod a+x <afile>
endif
endfunction
au BufWritePost * call ModeChange()