#!/bin/bash
#
# hack-watch - watch file and git commit all changes each time the file is
# changed
#

FILE=$1
DIR=$(dirname ${FILE})

echo -e "hack-watch in effect on: ${FILE} in dir: ${DIR}\n"

cd ${DIR}

while true; do
  inotifywait -qq -e CLOSE_WRITE ${FILE}
  git add ${FILE}
  git commit -m 'hack-watch commit'
  echo -e "commit\n"
done
