shithub: snippets

Download patch

ref: 1f4f888404943771791d9433de9be98ad30577fb
parent: d35571cbb83b144805ef9158233f3b148a32ff2d
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Jan 16 17:37:48 EST 2021

add watch

--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
 # Snippets
 
-Random snippets of code that are in public domain.
-Just copy and use for whatever you want.
+Random snippets of code and scripts that are in public domain.  Just
+copy and use for whatever you want.  Except for doing any kind of
+harm.
 
 * `c_builtins*` a few __builtin_* for Plan 9, useful for porting other software
 * `lrint.c` lrint* implementation
@@ -9,3 +10,5 @@
 * `nanosec.c` nanosec(), a replacement for (way more expensive) nsec()
 * `qt.[ch]` [QP tries](https://dotat.at/prog/qp/README.html)
 * `xml.[ch]` XML parser, works as a streaming parser as well
+
+* `watch` watch-like tool, imagine
--- /dev/null
+++ b/watch
@@ -1,0 +1,12 @@
+#!/bin/rc
+# calls a command every second, replacing its output with the new one
+
+rfork ne
+a0=''
+while(){
+	a=`"{$*}
+	echo -n $a0 | tr -c '' '\x08'
+	echo -n $a
+	a0=$a
+	sleep 1
+}