Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: update some core Unix completions
- X-seq: zsh-workers 37029
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: update some core Unix completions
- Date: Sat, 31 Oct 2015 01:53:20 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1446252801; bh=5p3zhL6MaugoP/9rIUvTuUmjnZFPpZwFglo6C3WslfA=; h=From:To:Subject:Date:From:Subject; b=qDGbb1lSHJOrMulrZOSVtMfvjuWbrGNA+GedUL9T9TJppkySQThx1ZycyJA9mdidoLPObO1W0hz7N+5bbQjc/oDS4XZj+w9LhCyIYcJIvw/E7XzDrpXizqDiQasytaAwsSTI2rnmTxrgmUsnAI9G4UClGeUOxuJ71+mpGfNZ+6LxHPmaNhKqlcRo1qQHN515Cmaj+06mLNuSwpcgJxkVpaey91W3LzuZFInUjbGqahhzf42I5JvWmR+jb8pwxvAfH+Ue0nws7CkCIHsIwDt8L02d8Z0QsaGRtQlZK5wxfNee28sQ4xk5l+clenbQWW+HRgcCMRhp2HQXSnKB1dc+Ww==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Checking release notes for recent BSD releases, OpenBSD's sed now
supports -i and FreeBSD's date allows -r to specify files. I also
checked the new head/tail completions against Solaris which didn't
amount to much: just tail -r. Finally, there's one new function: for tr.
Oliver
diff --git a/Completion/Unix/Command/_date b/Completion/Unix/Command/_date
index e596ac0..ff3bac3 100644
--- a/Completion/Unix/Command/_date
+++ b/Completion/Unix/Command/_date
@@ -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' )
;;
diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed
index 8e2385c..cc7a963 100644
--- a/Completion/Unix/Command/_sed
+++ b/Completion/Unix/Command/_sed
@@ -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+=(
diff --git a/Completion/Unix/Command/_tail b/Completion/Unix/Command/_tail
index 6e14453..fbe30f1 100644
--- a/Completion/Unix/Command/_tail
+++ b/Completion/Unix/Command/_tail
@@ -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
diff --git a/Completion/Unix/Command/_tr b/Completion/Unix/Command/_tr
new file mode 100644
index 0000000..d55fab5
--- /dev/null
+++ b/Completion/Unix/Command/_tr
@@ -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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author