4 ms·
So here's my little script that automatically commits the content directory to git on changes: interval_in_seconds=0.5 previous="" while true;
by ls15 4y ago
So here's my little script that automatically commits the content directory to git on changes:
interval_in_seconds=0.5
previous=""
while true;
do
x=$(ls -R -al ./content | md5);
if [[ "$x" != "$previous" ]]; then
previous=$x
git add *
git commit -m "Content update"
# ...
fi;
sleep $interval_in_seconds;
done
Of course it lacks a lot of the functionality that GitJournal has. It is just meant to keep a history of changes.
- vhanda 4y agoI started https://GitHub.com/GitJournal/git-auto-sync https://GitHub.com/GitJournal/git-auto-sync to do this exact thing. Just with an easier interface and proper tests. You can basically call `git-auto-sync daemon add`, and it will register itself as a systemd user process (on Linux, other OSs are also supported), and monitor that folder for changes + poll every x minutes. It's still in the early stages, but I'd love to get your feedback. Edit: Or you can just call `git-auto-sync sync` to commit + pull / rebase + push.
- pydry 4y agoI have something very similar to this with keybase e2e encrypted git and just triggered by a big button (on laptop/phone).
- john-tells-all 4y agoConsider updating your script to use Entr. It's specifically designed to efficiently and rapidly run code on file changes. More info from National Treasure Julia Evans: https://jvns.ca/blog/2020/06/28/entr/ https://jvns.ca/blog/2020/06/28/entr/ Something like this: git ls-files | entr autocommit.sh