Last active
December 15, 2015 08:49
-
-
Save esamattis/5233969 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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