alias monitor {
var %1 $1-
if ($1 == list) {
var %a 1
echo -a * /monitor's list:
while ($timer(%a)) {
if (monitor* iswm $v1) {
echo -a $longfn($mid($v2,8))
}
inc %a
}
}
elseif ($1 == off) {
:del
if ($hget(monitor,$shortfn($2-))) {
if ($show) echo -a * /monitor: $2- has been removed from the watched list
hdel monitor $shortfn($2-)
}
.timermonitor $+ $shortfn($2-) off
}
elseif ($exists(%1)) {
if ($isid) {
tokenize 32 $hget(monitor,$shortfn(%1))
;to add the check on $md5 too, use "if ($file(%1).mtime > $2) && ($md5(%1,2) != $1) {"
if ($file(%1).mtime > $2) {
echo -st %1 has changed (old md5: $1 - new md5: $md5(%1,2) $+ )
}
}
elseif ($show) echo -a * /monitor: $1- has been added from the watched list
hadd -m monitor $shortfn(%1) $md5(%1,2) $file(%1).mtime
.timermonitor $+ $shortfn(%1) -m 0 100 noop $!monitor( %1 )
}
else .timer -h 1 0 monitor off %1
}
This will echo in the status window when a file is changing, usage:
/monitor <filename> - Adds a filename to the watch list, do not quote the filename.
/monitor list - Lists all the filename you are currently watching
/monitor off <filename> - Removes the filename from the watch list