19 Jul 2016

File watching revisited
#!/usr/bin/env bash
# Usage:
# re-run ~/go-project make build


if [[ ! -x $(which fswatch) ]];then
  echo "Must install fswatch"
  exit 1
fi

main(){
  DIR_OR_FILE=$1
  shift
  CMD="$@"
  fswatch -or ${DIR_OR_FILE} | xargs -n1 -I{} -- ${CMD}
}

main "$@"