mirror of
				git://git.code.sf.net/p/zsh/code
				synced 2025-11-04 07:21:06 +01:00 
			
		
		
		
	Debian's gzip version has a --rsyncable option (see "gzip --help" output, the man page not being currently up to date). It should be supported by "/usr/share/zsh/functions/Completion/Unix/_gzip". Initially submitted to Debian at https://bugs.debian.org/702000
		
			
				
	
	
		
			96 lines
		
	
	
	
		
			3.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			96 lines
		
	
	
	
		
			3.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
#compdef gzip gunzip gzcat=gunzip -redirect-,<,gunzip=gunzip -redirect-,>,gzip=gunzip -redirect-,<,gzip=gzip -value-,GZIP,-default-
 | 
						|
 | 
						|
local decompress files expl curcontext="$curcontext" state line ret=1
 | 
						|
typeset -A opt_args
 | 
						|
 | 
						|
files=( '*:files:->files' )
 | 
						|
case "$service" in
 | 
						|
*GZIP*)
 | 
						|
  compset -q
 | 
						|
  words=( fake "$words[@]" )
 | 
						|
  (( CURRENT++ ))
 | 
						|
  files=()
 | 
						|
  ;&
 | 
						|
gunzip|zcat)
 | 
						|
  decompress=yes
 | 
						|
  ;&
 | 
						|
gzip)
 | 
						|
  _arguments -C -s -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]' \
 | 
						|
    '--rsyncable[make rsync-friendly archive]' \
 | 
						|
    '(--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[@]" && ret=0
 | 
						|
  ;;
 | 
						|
esac
 | 
						|
 | 
						|
case "$state" in
 | 
						|
files)
 | 
						|
  (( $+opt_args[-d] || $+opt_args[--decompress] || $+opt_args[--uncompress] ||
 | 
						|
     $+opt_args[-l] || $+opt_args[--list] ||
 | 
						|
     $+opt_args[-t] || $+opt_args[--test] )) &&
 | 
						|
    decompress=yes
 | 
						|
  if (( $+opt_args[-r] || $+opt_args[--recursive] )); then
 | 
						|
    if [[ -z "$decompress" ]]; then
 | 
						|
      _description directories expl 'directory to compress'
 | 
						|
      _files "$expl[@]" -/ && return
 | 
						|
    else
 | 
						|
      _description directories expl 'compressed directory'
 | 
						|
      _files "$expl[@]" -/ && return
 | 
						|
    fi
 | 
						|
  else
 | 
						|
    if [[ -z "$decompress" ]]; then
 | 
						|
      _description files expl 'file to compress'
 | 
						|
      _files "$expl[@]" -g '^*.(([tT]|)[gG]|)[zZ](-.)' && return
 | 
						|
    else
 | 
						|
      _description files expl 'compressed file'
 | 
						|
      if (( $+opt_args[-f] )); then
 | 
						|
	_files "$expl[@]" && return
 | 
						|
      else
 | 
						|
	_files "$expl[@]" -g '*.(([tT]|)[gG]|)[zZ](-.)' && return
 | 
						|
      fi
 | 
						|
    fi
 | 
						|
  fi
 | 
						|
  ;;
 | 
						|
esac
 | 
						|
 | 
						|
return ret
 |