From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2638 invoked by alias); 31 Oct 2015 00:59:34 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37029 Received: (qmail 22531 invoked from network); 31 Oct 2015 00:59:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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== X-Yahoo-Newman-Id: 730103.55966.bm@smtp125.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: I.HyenYVM1lkgzR7PUlyuREbqPXo0157VTPhb1.mBIuPSwk Ac5NTymx4rEOTXEjflOsSKN6PF_pUKe8hsPJ7gNKhu0vUSo3OMZNrSHGoFDs 4EYuC1J.aZWqlwcNzkwC_hYdb_ewAGxlu7d98Dj1rU5pE6qS2GJ3KLL8NJAJ rbey_LXp23n3c2DMkjYFoxLXW58NHpUmYMi6pWTPTEqUn0Ym1X2huCtWSlKD .PBHZCCHKeuCyCsIYDFOcj3pcHT_fNLyVJH38Os7.zIPVHQ.U5LoeKxXn2OI jbdeNmtzXwWViAUREpIKPWQh5LKu0ZfJeKlktVzQ20wmEg9iQIxaGCj2sOOB njt2AX7CpbMCrd..I9uzgylWhaB4h3NmFmWpDs52ku9t9irK4frGkklkQK.r R1Lb7jUPB3vYIgMAUg8gu9zJE1yPp3NayKayyUoiyBgFrL1mgyAgOL7Rp1q0 qrYHsN1fJfjen9AR5Ztxnm3kzylWZWlCslQJ4OqGMRATnR62yZ..QEV7Xh4k EXLbCAemuzVFTjE8rnmlnEcywy7s1cw-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: update some core Unix completions MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22782.1446252800.1@thecus.kiddle.eu> Date: Sat, 31 Oct 2015 01:53:20 +0100 Message-ID: <22783.1446252800@thecus.kiddle.eu> 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