summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2015-10-31 19:14:36 +0100
committerOliver Kiddle <opk@zsh.org>2015-10-31 19:14:36 +0100
commitfa59375e36e1718e060048ba7efd7346b3c8e94a (patch)
tree217f4c0133da5ebb0be1dae23962653cbdb59f16 /Completion/Unix/Command
parent098319df9922441ca70c233195151cb1965556a8 (diff)
downloadzsh-fa59375e36e1718e060048ba7efd7346b3c8e94a.tar.gz
zsh-fa59375e36e1718e060048ba7efd7346b3c8e94a.tar.xz
zsh-fa59375e36e1718e060048ba7efd7346b3c8e94a.zip
37029: update options and new tr completion
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_date17
-rw-r--r--Completion/Unix/Command/_sed8
-rw-r--r--Completion/Unix/Command/_tail14
-rw-r--r--Completion/Unix/Command/_tr53
4 files changed, 78 insertions, 14 deletions
diff --git a/Completion/Unix/Command/_date b/Completion/Unix/Command/_date
index e596ac038..ff3bac398 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 8e2385cc8..cc7a9631d 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 6e1445328..fbe30f13a 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 000000000..d55fab5ff
--- /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