watch icon indicating copy to clipboard operation
watch copied to clipboard

Doesn't support configurable intervals (and other watch options).

Open iMartyn opened this issue 5 years ago • 5 comments

Looking at the code, this implementation of watch only has an interval of 1 second. For commands that are heavy on resources, that's too frequent.

In normal (gnu?) watch you can set an interval and other options :

/usr/bin/watch --help

Usage:
 watch [options] command

Options:
  -b, --beep             beep if command has a non-zero exit
  -c, --color            interpret ANSI color and style sequences
  -d, --differences[=<permanent>]
                         highlight changes between updates
  -e, --errexit          exit if command has a non-zero exit
  -g, --chgexit          exit when output from command changes
  -n, --interval <secs>  seconds to wait between updates
  -p, --precise          attempt run command in precise intervals
  -t, --no-title         turn off header
  -x, --exec             pass command to exec instead of "sh -c"

 -h, --help     display this help and exit
 -v, --version  output version information and exit

For more details see watch(1).

It would be good to have those implemented. Also, amusingly watch --help in this implementation tries to watch a command --help. The experienced unix admin knows that to pass arguments to apps they have to push a -- separator, so watch -c -n30 -- ls -c but if you do this, be sure to document :-)

iMartyn avatar Apr 03 '20 12:04 iMartyn

What about watch 30s command name?

antonmedv avatar Apr 03 '20 12:04 antonmedv

I'd recommend using flag or cobra flags to try and match the options in the current watch command as you'll get more adoption if it's a drop-in replacement. Then you can also map WATCH_COMMAND to -x.

iMartyn avatar Apr 03 '20 13:04 iMartyn

I just found this, and I'm interested in the same thing. I could submit a PR for this if you like?

ghostsquad avatar May 14 '20 21:05 ghostsquad

Okay 👌

antonmedv avatar May 15 '20 08:05 antonmedv

I'll submit a PR to introduce optional flags, and include the interval flag. That should at least be enough to then get started on adding other flags

ghostsquad avatar May 15 '20 17:05 ghostsquad