summaryrefslogtreecommitdiffstats
path: root/Completion/Unix/Command/_watch
blob: a648e3e37a3acc11a24154dcbf2d9ccf0b5da000 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#compdef watch

local variant ret=1
local -a context line state state_descr
local -A opt_args

_pick_variant -r variant procps=procps $OSTYPE --version

case $variant in
  (procps)
    _arguments -s -S -A '-*' : \
      '(: * -)'{-h,--help}'[display help information]' \
      '(: * -)'{-v,--version}'[display version information]' \
      '(-b --beep)'{-b,--beep}'[beep on non-zero command exit]' \
      '(-c --color)'{-c,--color}'[interpret ANSI color/style sequences]' \
      '(-d --differences)'{-d-,--differences=-}'[highlight changes between updates]::how to highlight:(permanent)' \
      '(-e --errexit)'{-e,--errexit}'[pause updating if command exits with a non-zero exit code]' \
      '(-g --chgexit)'{-g,--chgexit}'[exit on command output change]' \
      '(-n --interval)'{-n+,--interval=}'[specify update interval]:update interval (seconds) [2]' \
      '(-p --precise)'{-p,--precise}'[run command at precise intervals]' \
      '(-q --equexit)'{-q+,--equexit=}'[exit when output of command does not change for the given cycles]:cycles' \
      '(-r --no-rerun)'{-r,--no-rerun}'[do not run the program on terminal resize]' \
      '(-t --no-title)'{-t,--no-title}'[disable header]' \
      '(-w --no-wrap)'{-w,--no-wrap}'[disable line wrapping]' \
      '(-x --exec)'{-x,--exec}'[pass command to exec(2) instead of `sh -c`]' \
      '(-)*::: :->cmd' && ret=0
  ;;
  openbsd*)
    _arguments -s -A "-*" \
      '(-l -w)-c[highlight changed characters]' \
      '-e[pause updating if command exits with a non-zero exit code]' \
      '(-c -w)-l[highlight changed lines]' \
      '-s[set the interval between updates]: :_numbers -d 1 -u seconds interval' \
      '(-c -l)-w[highlight changed words]' \
      '-x[pass command to execl(3) instead of `sh -c`]' \
      '(-)*::: :->cmd' && ret=0
  ;;
  # watch(1) has completely different semantics on freebsd compared to linux, hence:
  (freebsd*|dragonfly*) _watch-snoop "$@" && ret=0 ;;
  (*) _default && ret=0 ;;
esac

[[ $state == cmd ]] &&
if
  (( CURRENT == 1 )) &&
  [[ $words[1] == (\"|\'|\$\')* ]] &&
  [[ -z $opt_args[(i)(-x|--exec)] ]]
then
  _cmdstring && ret=0
else
  _normal -p watch && ret=0
fi

return ret