All you really need is a simple shell script.  You can copy this to
your ~/bin/ directory:

--- cat ~/bin/watch --------------------------------------------------
#!/bin/sh
# watch: repeatedly run a command to watch its output change
######################################################################

WAIT=1

while :
do
        C=$((`stty -a | awk '/columns/ {print $6}'` - 34))
        L=$((`stty -a | awk '/rows/ {print $4}'` - 3))
        clear
        printf "%s     %${C}.${C}s\n\n" "`date`" "${*}"
        eval "${*}" | cut -b1-$((C+34)) | head -n${L}
        sleep ${WAIT}
done
----------------------------------------------------------------------

I've also attached it for convenience.  It's trivial, and you can
adjust to your preferences rather easily.

Paul 'WEiRD' de Weerd

On Mon, May 15, 2023 at 07:26:58PM +0000, Simon Ryabinkov wrote:
| Dear OpenBSD Team,
| 
| I am excited to submit a feature request for OpenBSD!
| 
| Feature: watch(1) utility
| 
| Feature Description: watch(1) runs command repeatedly, displaying
| its output and errors (the first screenfull). This allows you to
| watch the program output change over time. By default, command is
| run every 2 seconds and watch will run until interrupted.
| 
| Sample Code: my naive implementation
| https://github.com/ssleert/watch/blob/master/watch.c
| if you need it I can add a man page and fix the style guide
| and try to add to sources and send the diff file.
| 
| If there are any problems with the code,
| let me know and I will try to fix them.
| 
| Thanks for your consideration,
| Simon

-- 
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 
#!/bin/sh
# watch: repeatedly run a command to watch its output change
######################################################################

WAIT=1

while :
do
        C=$((`stty -a | awk '/columns/ {print $6}'` - 34))
        L=$((`stty -a | awk '/rows/ {print $4}'` - 3))
        clear
        printf "%s     %${C}.${C}s\n\n" "`date`" "${*}"
        eval "${*}" | cut -b1-$((C+34)) | head -n${L}
        sleep ${WAIT}
done

Reply via email to