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
55
56
57
58
59
60
61
62
63
64
65
66
|
#compdef tail gtail
local curcontext=$curcontext state state_descr line opts args ret=1
typeset -A opt_args
if _pick_variant gnu=GNU unix --version; then
args=(
'(-n --lines -c --bytes)'{-c+,--bytes=}'[print the last specified bytes; with +, start at the specified byte]:number of bytes:->number'
'(-n --lines -c --bytes)'{-n+,--lines=}'[print the last specified lines; with +, start at the specified line]:number of lines:->number'
'(-F -f)--follow=-[output appended data as the file grows]::how:(name descriptor)'
'(-F --follow)-f[same as --follow=descriptor]'
'(-f --follow --retry)-F[same as --follow=name --retry]'
'--max-unchanged-stats=[with --follow=name, check file rename after the specified number of iterations]:number of iterations'
'(-s --sleep-interval)'{-s+,--sleep-interval=}'[with -f, sleep the specified seconds between iterations]:seconds'
'--pid=[with -f, terminate after the specified process dies]:pid:_pids'
'(-q --quiet --silent -v --verbose)'{-q,--quiet,--silent}'[never output headers giving file names]'
'(-q --quiet --silent -v --verbose)'{-v,--verbose}'[always output headers giving file names]'
'--retry[keep trying to open a file even when it becomes inaccessible]'
'(- *)--help[display help and exit]'
'(- *)--version[output version information and exit]'
)
else
opts=(-A '-*')
args=(
'(-b -n)-c+[start at the specified byte]:bytes relative to the end (with +, beginning) of file'
'(-b -c)-n+[start at the specified line]:lines relative to the end (with +, beginning) of file'
'(-F -r)-f[wait for new data to be appended to the file]'
)
case $OSTYPE in
(freebsd*|darwin*|dragonfly*|netbsd*|openbsd*|solaris*)
args+=(
'(-f -F)-r[display the file in reverse order]'
)
;|
(freebsd*|darwin*|dragonfly*|netbsd*|openbsd*)
args+=(
'(-c -n)-b+[start at the specified block (512-byte)]:blocks relative to the end (with +, beginning) of file'
)
;|
(freebsd*|darwin*|dragonfly*|netbsd*)
args+=(
'(-f -r)-F[implies -f, but also detect file rename]'
'(-v)-q[never output headers giving file names]'
)
;|
(dragonfly*|netbsd*)
args+=( '(-q)-v[always output headers giving file names]' )
;;
esac
fi
_arguments -C -s -S $opts : $args '*:file:_files' && return
case $state in
(number)
local alts
[[ -z $PREFIX ]] && alts=(
'sign:sign:((-\:"print all but the last specified bytes/lines" +\:"print the first specified bytes/lines (default)"))'
)
compset -P '+'
alts+=( 'numbers: :_numbers -N $state_descr b\:512 K\:1024 KB\:1000 M\:1024\^2 MB\:1000\^2 G\:1024\^3 GB\:1000\^3 T\:1024\^4 TB\:1000\^4' )
_alternative $alts && ret=0
;;
esac
return ret
|