Revisions
-
mikesmullin revised this gist
Aug 31, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ shift cmd=$* sha=0 update_sha() { sha=`ls -lR --time-style=full-iso $path | sha1sum` } update_sha previous_sha=$sha -
mikesmullin created this gist
Aug 31, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #!/usr/bin/env bash # script: watch # author: Mike Smullin <[email protected]> # license: GPLv3 # description: # watches the given path for changes # and executes a given command when changes occur # usage: # watch <path> <cmd...> # path=$1 shift cmd=$* sha=0 update_sha() { sha=`ls -lR $path | sha1sum` } update_sha previous_sha=$sha build() { echo -en " building...\n\n" $cmd echo -en "\n--> resumed watching." } compare() { update_sha if [[ $sha != $previous_sha ]] ; then echo -n "change detected," build previous_sha=$sha else echo -n . fi } trap build SIGINT trap exit SIGQUIT echo -e "--> Press Ctrl+C to force build, Ctrl+\\ to exit." echo -en "--> watching \"$path\"." while true; do compare sleep 1 done