#!/bin/sh # Execute given command when current dir content changes. trap exit SIGINT while true; do "$@" x=$? c=$((c+1)) echo "# $c $(date +%H:%M:%S): $@: exit $x" fswatch -1 . >/dev/null 2>&1 done