mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-22 16:20:23 +02:00
37029: update options and new tr completion
This commit is contained in:
parent
098319df99
commit
fa59375e36
5 changed files with 82 additions and 14 deletions
|
@ -1,5 +1,9 @@
|
|||
2015-10-31 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 37029: Completion/Unix/Command/_date,
|
||||
Completion/Unix/Command/_sed, Completion/Unix/Command/_tail,
|
||||
Completion/Unix/Command/_tr: update options and new tr completion
|
||||
|
||||
* 37028: Completion/Redhat/Command/_scl: new completion
|
||||
|
||||
* 36993: Eric Cook: Functions/Misc/zed: fix argument parsing
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#compdef date gdate
|
||||
|
||||
local -a args
|
||||
local -a args alts
|
||||
|
||||
if _pick_variant gnu="Free Software Foundation" unix --version; then
|
||||
args=(
|
||||
|
@ -20,16 +20,27 @@ else
|
|||
solaris*)
|
||||
args=( '-a:adjustment' )
|
||||
;;
|
||||
darwin*|dragonfly*|netbsd*|openbsd*)
|
||||
args+=( '-r[specify reference time]:seconds since epoch' )
|
||||
;|
|
||||
freebsd*|darwin*|dragonfly*|netbsd*|openbsd*)
|
||||
args=(
|
||||
'-n[only set time on current machine]'
|
||||
'-d:daylight saving time value'
|
||||
'-j[do not try to set date]'
|
||||
'-r:seconds since epoch'
|
||||
'-t:minutes west of GMT'
|
||||
)
|
||||
;|
|
||||
freebsd*) args+=( '-R[RFC2822 format]' ) ;|
|
||||
freebsd*)
|
||||
alts=(
|
||||
'seconds:sec:_guard "(0x[0-9a-fA-F]#|[0-9]#)" "seconds since epoch"'
|
||||
'files:file:_files'
|
||||
)
|
||||
args+=(
|
||||
'-r[reference time: file modification or literal time]:reference: _alternative $alts'
|
||||
'-R[RFC2822 format]'
|
||||
)
|
||||
;|
|
||||
freebsd*|dragonfly*|darwin*)
|
||||
args+=( '-f:parsing format' '-v:adjustment value' )
|
||||
;;
|
||||
|
|
|
@ -38,12 +38,8 @@ else
|
|||
'-a[delay opening files listed with w function]'
|
||||
)
|
||||
;|
|
||||
darwin*|freebsd*|netbsd*)
|
||||
args+=(
|
||||
'-i'$inplace
|
||||
'-l[make output line buffered]'
|
||||
)
|
||||
;|
|
||||
darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i'$inplace ) ;|
|
||||
darwin*|freebsd*|netbsd*) args+=( '-l[make output line buffered]' ) ;|
|
||||
freebsd*) args+=( '-u[disable data buffering]' ) ;|
|
||||
freebsd*|netbsd*)
|
||||
args+=(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#compdef tail
|
||||
|
||||
local curcontext=$curcontext state state_descr line expl opts args ret=1
|
||||
local curcontext=$curcontext state state_descr line opts args ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
if _pick_variant gnu=GNU unix --version; then
|
||||
|
@ -27,9 +27,13 @@ else
|
|||
'(-F -r)-f[wait for new data to be appended to the file]'
|
||||
)
|
||||
case $OSTYPE in
|
||||
(freebsd*|darwin*|dragonfly*|netbsd*|openbsd*)
|
||||
(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'
|
||||
)
|
||||
;|
|
||||
|
@ -42,14 +46,14 @@ else
|
|||
esac
|
||||
fi
|
||||
|
||||
_arguments -C -s -S $opts : $args '*:file:_files' && return 0
|
||||
_arguments -C -s -S $opts : $args '*:file:_files' && return
|
||||
|
||||
case $state in
|
||||
(number)
|
||||
local mlt sign digit
|
||||
mlt='multiplier:multiplier:((b\:512 K\:1024 KB\:1000 M\:1024\^2'
|
||||
mlt='multipliers:multiplier:((b\:512 K\:1024 KB\:1000 M\:1024\^2'
|
||||
mlt+=' MB\:1000\^2 G\:1024\^3 GB\:1000\^3 T\:1024\^4 TB\:1000\^4))'
|
||||
sign='sign:sign:((+\:"start at the specified byte/line"'
|
||||
sign='signs:sign:((+\:"start at the specified byte/line"'
|
||||
sign+=' -\:"output the last specified bytes/lines (default)"))'
|
||||
digit='digits:digit:(0 1 2 3 4 5 6 7 8 9)'
|
||||
if compset -P '*[0-9]'; then
|
||||
|
|
53
Completion/Unix/Command/_tr
Normal file
53
Completion/Unix/Command/_tr
Normal file
|
@ -0,0 +1,53 @@
|
|||
#compdef tr
|
||||
|
||||
local curcontext="$curcontext" state line expl ret=1
|
||||
local args variant
|
||||
local -A descr
|
||||
descr=(
|
||||
-c '[complement characters specified by first string]'
|
||||
-d '[delete specified characters from input]'
|
||||
-s '[squeeze repeated instances of character to a single instance]'
|
||||
)
|
||||
|
||||
_pick_variant -r variant gnu=GNU $OSTYPE --version
|
||||
case $variant in
|
||||
gnu)
|
||||
args=(
|
||||
'(-c -C --complement)'{-c,-C,--complement}"${descr[-c]}"
|
||||
'(-d --delete 2)'{-d,--delete}"${descr[-d]}"
|
||||
'(-s --squeeze-repeats)'{-s,--squeeze-repeats}"${descr[-s]}"
|
||||
'(- 1 2)--help[display help information]'
|
||||
'(- 1 2)--version[display version information]'
|
||||
)
|
||||
;;
|
||||
darwin*|dragonfly*|*bsd*)
|
||||
args+=( "(-c)-C$descr[-c]" )
|
||||
;|
|
||||
darwin*|dragonfly*|freebsd*)
|
||||
args+=( '-u[guarantee that output is unbuffered]' )
|
||||
;|
|
||||
*)
|
||||
for k in c d s; do
|
||||
args+=( -$k$descr[$k] )
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
_arguments -C -s $args \
|
||||
'1:character set:->chsets' \
|
||||
'2:character set:->chsets' && ret=0
|
||||
|
||||
if [[ -n $state ]]; then
|
||||
if compset -P '*\[:'; then
|
||||
_wanted characters expl 'character class' \
|
||||
compadd -S ":${${QIPREFIX:+]}:-\]}$compstate[quote] " \
|
||||
alnum alpha blank cntrl digit graph lower print punct space upper \
|
||||
xdigit && return
|
||||
elif compset -P '*\\'; then
|
||||
_describe -t characters character \
|
||||
'(\\\\:backslash a:alert b:backspace f:form\ feed n:new\ line r:return t:tab v:vertical\ tab)' -S '' && return
|
||||
fi
|
||||
_message -e characters 'character set'
|
||||
fi
|
||||
|
||||
return ret
|
Loading…
Add table
Add a link
Reference in a new issue