Skip to content

Instantly share code, notes, and snippets.

@naokirin
Created June 21, 2013 11:09
Show Gist options
  • Save naokirin/5830524 to your computer and use it in GitHub Desktop.
Save naokirin/5830524 to your computer and use it in GitHub Desktop.
#!/bin/bash
# require package : inotify-tools
exclude=(--exclude \~ --exclude \.swp --exclude \.git/)
events=(-e CREATE -e MODIFY -e MOVED_TO -e DELETE)
if [ $# -eq 0 ]; then
echo 'start polling'
while inotifywait ${events[@]} -r ./ ${exclude[@]}; do
git now > /dev/null && git diff --stat HEAD^ || echo "failure"
done
elif [ $1 == "-r" ]; then
echo 'Managed files are'
echo "recursive ${*}"
echo 'start polling'
while inotifywait ${events[@]} $@ ${exclude[@]}; do
git now --managed ${@:2} > /dev/null && git diff --stat HEAD^ || echo 'faiulre'
done
else
echo 'Managed files are'
echo $@
echo 'start polling'
while inotifywait ${events[@]} $@ ${exclude[@]}; do
git now -managed $@ > /dev/null && git diff --stat HEAD^ || echo "failure"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment