Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Feeling homeSync? Sync your home dir to a git repo with launchd every 30 minutes (macOS)

Feeling homeSync?

  1. Place homeSync.sh and homeSync.plist in your home dir
  2. It's recommended to place the .gitignore in your home dir as well, to prevent checking in all your things :)

After doing that, run the following commands in ~/.

cd ~
git init
git remote add origin <https://your/git/repo.git>

cp homeSync.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homeSync.plist

If you're having issues, check the logging:

cat /tmp/homeSync.err
cat /tmp/homeSync.out
/*
!.bashrc
!.bash_history
!.gitignore
# Depending on your shell usage etc
!.zshrc
!.zsh_history
!homeSync.plist
!homeSync.sh
/*/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homeSync</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>~/homeSync.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/homeSync.err</string>
<key>StandardOutPath</key>
<string>/tmp/homeSync.out</string>
<key>StartInterval</key>
<integer>1800</integer>
</dict>
</plist>
cd
git add .
git commit -m "homeSynced @ $(date)"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.