Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
_gzip and _zcat
- X-seq: zsh-workers 10890
- From: Tanaka Akira <akr@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: _gzip and _zcat
- Date: 22 Apr 2000 03:35:42 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
This is completion function for gzip, gunzip and zcat.
Completion/User/_gunzip should be removed after this patch is applied.
Index: Completion/User/_gzip
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_gzip,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 _gzip
--- Completion/User/_gzip 2000/02/10 12:48:30 1.1.1.6
+++ Completion/User/_gzip 2000/04/21 18:22:02
@@ -1,6 +1,82 @@
-#compdef gzip
+#compdef gzip gunzip gzcat
+local decompress
local expl
+local curcontext="$curcontext" state line
+typeset -A opt_args
-_description files expl 'file to compress'
-_files "$expl[@]" -g '*~*.([tT]|)[gG][zZ]'
+case "${words[1]:t}" in
+gunzip|zcat|gzcat)
+ decompress=yes
+ ;&
+gzip)
+ _arguments -s \
+ '(--to-stdout --stdout)-c[write on standard output]' \
+ '(-c --stdout)--to-stdout[write on standard output]' \
+ '(-c --to-stdout)--stdout[write on standard output]' \
+ '(--decompress --uncompress)-d[decompress]' \
+ '(-d --uncompress)--decompress[decompress]' \
+ '(-d --decompress)--uncompress[decompress]' \
+ '(--force)-f[force overwrite]' \
+ '(-f)--force[force overwrite]' \
+ '(--help)-h[display help message]' \
+ '(-h)--help[display help message]' \
+ '(--list)-l[list compressed file contents]' \
+ '(-l)--list[list compressed file contents]' \
+ '(--license)-L[display software license]' \
+ '(-L)--license[display software license]' \
+ '(--no-name)-n[do not save or restore the original name and time stamp]' \
+ '(-n)--no-name[do not save or restore the original name and time stamp]' \
+ '(--name)-N[save or restore the original name and time stamp]' \
+ '(-N)--name[save or restore the original name and time stamp]' \
+ '(--quiet --silent)-q[suppress all warnings]' \
+ '(-q --silent)--quiet[suppress all warnings]' \
+ '(-q --quiet)--silent[suppress all warnings]' \
+ '(--recursive)-r[operate recursively on directories]' \
+ '(-r)--recursive[operate recursively on directories]' \
+ '(--suffix)-S+[specify suffix for compressed files]:suffix:' \
+ '(-S)--suffix=[specify suffix for compressed files]:suffix:' \
+ '(--test)-t[test compressed file integrity]' \
+ '(-t)--test[test compressed file integrity]' \
+ '(--verbose)-v[verbose mode]' \
+ '(-v)--verbose[verbose mode]' \
+ '(--version)-V[display version number]' \
+ '(-V)--version[display version number]' \
+ '( -1 -2 -3 -4 -5 -6 -7 -8 -9 --best)--fast' \
+ '(--fast -2 -3 -4 -5 -6 -7 -8 -9 --best)-1' \
+ '(--fast -1 -3 -4 -5 -6 -7 -8 -9 --best)-2' \
+ '(--fast -1 -2 -4 -5 -6 -7 -8 -9 --best)-3' \
+ '(--fast -1 -2 -3 -5 -6 -7 -8 -9 --best)-4' \
+ '(--fast -1 -2 -3 -4 -6 -7 -8 -9 --best)-5' \
+ '(--fast -1 -2 -3 -4 -5 -7 -8 -9 --best)-6' \
+ '(--fast -1 -2 -3 -4 -5 -6 -8 -9 --best)-7' \
+ '(--fast -1 -2 -3 -4 -5 -6 -7 -9 --best)-8' \
+ '(--fast -1 -2 -3 -4 -5 -6 -7 -8 --best)-9' \
+ '(--fast -1 -2 -3 -4 -5 -6 -7 -8 -9 )--best' \
+ '*:files:->files'
+ ;;
+esac
+
+case "$state" in
+files)
+ (( $+opt_args[-d] || $+opt_args[--decompress] || $+opt_args[--uncompress] )) &&
+ decompress=yes
+ if (( $+opt_args[-r] || $+opt_args[--recursive] )); then
+ if [[ -z "$decompress" ]]; then
+ _description directories expl 'directory to compress'
+ _files "$expl[@]" -/
+ else
+ _description directories expl 'compressed directory'
+ _files "$expl[@]" -/
+ fi
+ else
+ if [[ -z "$decompress" ]]; then
+ _description files expl 'file to compress'
+ _files "$expl[@]" -g '*~*.(([tT]|)[gG]|)[zZ]'
+ else
+ _description files expl 'compressed file'
+ _files "$expl[@]" -g '*.(([tT]|)[gG]|)[zZ]'
+ fi
+ fi
+ ;;
+esac
--- /dev/null Wed May 6 05:32:27 1998
+++ Completion/User/_zcat Sat Apr 22 03:22:25 2000
@@ -0,0 +1,20 @@
+#compdef zcat
+
+(( $+_is_gnu )) || typeset -gA _is_gnu
+
+if (( ! $+_is_gnu[$words[1]] )); then
+ if [[ $(_call version $words[1] --license </dev/null 2>&1) = *GNU* ]]
+ then
+ _is_gnu[$words[1]]=yes
+ else
+ _is_gnu[$words[1]]=
+ fi
+fi
+
+if [[ -n "$_is_gnu[$words[1]]" ]]
+then
+ _gzip "$@"
+else
+ _description files expl 'compressed file'
+ _files "$expl[@]" -g '*.Z'
+fi
--
Tanaka Akira
Messages sorted by:
Reverse Date,
Date,
Thread,
Author