Created
August 17, 2014 02:18
-
-
Save theepicsnail/e75a143b0cd017c82054 to your computer and use it in GitHub Desktop.
This file contains 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
alias watch="bash ~/watch.sh" | |
# watch foo.js bar.js -- ./runTests.sh | |
# runs runTests.sh, then waits for foo.js or bar.js to be modiified | |
# then reruns runTests.sh (kills the old process if it's still alive) |
This file contains 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/bash | |
# find -- | |
split="-1" | |
for (( i = 0; i < ${#@}; i++ )); do | |
if [ "${!i}" == "--" ] | |
then | |
split=$i | |
i=${#@} | |
fi | |
done | |
if [ "$split" == "-1" ] | |
then | |
echo "Missing --" | |
echo "Expected $0 files ... -- command..." | |
exit 1 | |
fi | |
FILES=${@:1:$split-1} | |
shift $split | |
function quit () { | |
end | |
exit 0 | |
} | |
trap quit SIGINT | |
PID=0 | |
function end() { | |
if [ $PID -ne 0 ] | |
then | |
kill $PID 2>&1 >/dev/null | |
echo "Killed $PID" | |
fi | |
} | |
function begin() { | |
$* & | |
echo "Started $*" | |
PID=$! | |
} | |
begin $* | |
while true | |
do | |
inotifywait -q -e MODIFY ${FILES[@]} | |
end | |
begin $* | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment