Skip to content

Instantly share code, notes, and snippets.

@esamattis
Last active December 15, 2015 08:49
Show Gist options
  • Save esamattis/5233969 to your computer and use it in GitHub Desktop.
Save esamattis/5233969 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Simple watch tool
# Homepage https://gist.github.com/epeli/5233969/
# Deps:
# sudo apt-get install inotify-tools
COMMAND=$@
set -eu
help() {
echo "
Run command on file changes.
usage: $(basename $0) <command>
"
}
[ "$COMMAND" = "--help" -o "$COMMAND" = "-h" ] && help && exit 0
[ -z "$COMMAND" ] && help && exit 1
RED="\033[31m"
GREEN="\033[32m"
RESET="\033[0m"
while true
do
sh -c "$COMMAND" && {
echo -e "${GREEN}Build OK!${RESET}"
} || {
echo -e "${RED}Build broken!${RESET}"
}
inotifywait --event modify --recursive .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment