Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save glassdimly/eadbf7da77549c49e55859b370bb9f7e to your computer and use it in GitHub Desktop.
Save glassdimly/eadbf7da77549c49e55859b370bb9f7e to your computer and use it in GitHub Desktop.

##Mac GitWatch

Based heavily on: https://gist.github.com/kbdluv/0ad7effe175e5f52d79078f422eab463#file-git-watch-sh

This watches the list of dirs in $repos. Remove mine and add your own. It will watch for changes and then commit and push the result.

To make this run and stay alive, you have to use automator to make an Application script.

Source: https://stackoverflow.com/questions/6442364/running-script-upon-login-mac

Here's a screenshot of what I did: https://stackoverflow.com/questions/6442364/running-script-upon-login-mac

Then you can run this app on login with the plist below.

<?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>com.gitwatch</string>
<key>KeepAlive</key>
<true/>
<key>Program</key>
<string>/Applications/gitwatch.app/Contents/MacOS/Application\U00A0Stub</string>
</dict>
</plist>
#!/bin/bash
cd "$1" && git add . && git commit -m "unattended" && git push
#!/bin/bash
# PATH for launchd to find `fswatch`
export PATH="/usr/local/bin:$PATH"
repos=(
'/Users/jeremy/Dropbox/Writer/MyNovel'
'/Users/jeremy/Dropbox/Writer/Journal'
);
sleeptime=300
for repo in ${repos[*]}
do
echo $repo
fswatch -r "$repo" | (sleep $sleeptime; grep --line-buffered -v '\/.git\/';) | xargs -n1 -I{} /Users/Jeremy/bin/git-commit-unattended.sh "$repo" &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment