Я использую это в MacVim Custom Version 8.0.648 (134)
" if file is executable just exit
au BufWritePost *.sh if FileExecutable("%") | if getline(1) =~ "^#!" | silent !chmod u+x % | endif | endif
" Determines if file is already executable
function! FileExecutable(fname)
execute "silent! ! test -x" a:fname
return v:shell_error
endfunction