1#compdef timeout gtimeout
2
3local args
4
5if [[ $service = g* || $OSTYPE != *bsd* ]]; then
6  # GNU coreutils as opposed to Free/NetBSD implementation
7  args=(
8    '(-v --verbose)'{-v,--verbose}'[indicate when signal is sent upon timeout]'
9    '(- *)--help[display usage information]'
10    '(- *)--version[display version information]'
11  )
12fi
13
14_arguments -S -A "-" $args \
15  '--preserve-status[always exit with the same status as command even if it times out]' \
16  "--foreground[don't propagate timeout to the command children]" \
17  '(-s --signal)'{-s,--signal}'[specify the signal to send on timeout]:signal:_signals' \
18  '(-k --kill-after)'{-k,--kill-after}'[followup first signal with SIGKILL if command persists after specified time]:time:time' \
19  '1: :_guard "[0-9.]#([smhd]|)" duration' \
20  '*:::command:_normal'
21