To use watchman, run watchman file-to-watch sleep-time command-to-execute
like so.
watchman test.txt 1 echo 'Tada!'
function watchman --description "watchman <file> <wait-time> <command>" | |
set initial_time (stat -f '%Z' $argv[1]) | |
while true | |
set changed_time (stat -f '%Z' $argv[1]) | |
if [ $initial_time != $changed_time ] | |
eval $argv[3..-1] | |
set initial_time $changed_time | |
end | |
sleep $argv[2] | |
end | |
end |
function watchman { | |
initial_time=$(stat -f '%Z' $1) | |
while true; do | |
changed_time=$(stat -f '%Z' $1) | |
if [ $initial_time != $changed_time ]; then | |
eval ${@:3} | |
initial_time=$changed_time | |
fi | |
sleep $2 | |
done | |
} |