Skip to content

Instantly share code, notes, and snippets.

@aprxi
Last active April 6, 2019 15:39
Show Gist options
  • Save aprxi/c826e01311df2a09dde28fdb88133591 to your computer and use it in GitHub Desktop.
Save aprxi/c826e01311df2a09dde28fdb88133591 to your computer and use it in GitHub Desktop.
vimrc-autocommit
" command W !git diff-index --quiet HEAD || git commit -am auto
" autocmd BufWritePost * call AutoCommit()
command W call AutoCommit()
function! AutoCommit()
execute ':w'
call system('git rev-parse --git-dir > /dev/null 2>&1')
if v:shell_error
return
endif
let message = '__auto_update__:' . expand('%:.')
call system('git add ' . expand('%:p'))
call system('git commit -m ' . shellescape(message, 1))
endfun
command P call AutoPush()
function! AutoPush()
execute ':W'
call system('git push')
endfun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment