Last active
April 6, 2019 15:39
-
-
Save aprxi/c826e01311df2a09dde28fdb88133591 to your computer and use it in GitHub Desktop.
vimrc-autocommit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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