Skip to content

Instantly share code, notes, and snippets.

@tyru
Created January 22, 2011 15:52
Show Gist options
  • Save tyru/791189 to your computer and use it in GitHub Desktop.
Save tyru/791189 to your computer and use it in GitHub Desktop.
" Automatic `:!chmod +x %`.
command! -bar DisableAutoChmod let b:disable_auto_chmod = 1
autocmd BufWritePost * call s:auto_chmod()
function! s:auto_chmod()
if !exists('b:disable_auto_chmod')
\ && getfperm(expand('%'))[2] !=# 'x'
\ && getline(1) =~# '^#!'
!chmod +x %
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment