I'll start by saying that I never wrote any VimScript or done any advanced configuration in my
.vimrc. I'm a super noob 😅. Bear with me.
I've been trying to backup my VimWiki on Git. I want to add some redundancy to the Dropbox setup already in place.
I've been following the instructions here:
augroup vimwiki au! BufWritePost ~/vimwiki/* !git add "%";git commit -m "Auto commit of %:t." "%" augroup END
For my first test, I saved the wiki index. I got this error:
!git add "/Users/gio/Dropbox/vimwiki/markdown/index.md" fatal: /Users/gio/Dropbox/vimwiki/markdown/index.md: '/Users/gio/Dropbox/vimwiki/markdown/index.md' is outside repository at '/Users/gio/dotfiles'
/Users/gio/dotfiles is the folder from where I opened Vim.
/Users/gio/Dropbox/vimwiki, saving the file results in the commit. But that's annoying, I'd like to be able to open the wiki from anywhere and commit and push the changes on every save.
I tried to add a
popd to the mix, like this:
" Backup on Git function CommitChangeInWiki() !pushd ~/Dropbox/vimwiki !git add "%" !git commit -m "Auto commit of %:t." "%" !popd endfunction au! BufWritePost ~/Dropbox/vimwiki/**/* call CommitChangeInWiki()
It doesn't work, though. I can see that
pushd is called.
I'm clearly missing something here. Thanks for your help.