my dotz
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

add witness for watching

+23
+23
bin/witness
··· 1 + #!/bin/sh 2 + # 3 + # witness - watch a file for changes & run a command 4 + 5 + file="$1" 6 + shift 7 + command="$@" 8 + 9 + get_access_time() { 10 + stat -c %Z "$1" 11 + } 12 + 13 + ltime="$(get_access_time "$file")" 14 + 15 + while true; do 16 + atime="$(get_access_time "$file")" 17 + if [ "$atime" != "$ltime" ]; then 18 + printf "witness: '%s' changed, running '%s'\n" "$file" "$command" 19 + $command 20 + ltime="$atime" 21 + fi 22 + sleep 0.5 23 + done