obsync is a Bash script wrapper for Obsidian on Linux that provides automated Git syncing for all Obsidian vaults.
The script requires:
inotify-tools- for file watchingjq- for JSON parsing- Standard Obsidian config location:
~/.config/obsidian/obsidian.json
- Parse
obsidian.jsonto find all vault paths - Store them in an array
- Iterate through each vault
- Check if it is a git repo
- Run
git pull --rebaseto ensure local files are up to date
- Start obsidian as a background process (
&) - Capture its Process ID (PID)
While the Obsidian PID is running:
- Use
inotifywaitin recursive monitor mode (-m -r) on the vault directories - Listen for
close_writeandmoved_toevents
- When an event triggers, start a cooldown timer (e.g., 60 seconds)
- If another event triggers before 60s, reset the timer (wait for the user to stop typing)
- Once the 60s timer expires without new events:
git add .
git commit -m "Auto-save: $(date)"- (Optional) Run
git push
- Wait for the Obsidian PID to exit (using
wait $PID) - Immediately run a final:
git add .git commit -m "Session end"git push
- Output a notification (using
notify-send) confirming the sync is complete
- ✅ Handle spaces in file paths correctly
- ✅ Do not push if the commit fails (empty commit)
- Late stage: Added a
--installhelper - Late stage: Added a handler to stash and pop "sando" when changes are made before the program is installed, files edited outside Obsidian, and so on
-Michael, yes that Michael. I'm sorry too. Please stop sending pizza. It's getting weird. The delivery guy is my best man at the wedding.