split gzip completion

This commit is contained in:
Guillaume Rousse 2009-05-17 22:01:43 +02:00
parent 996c9c2034
commit eee9d4f05f
2 changed files with 44 additions and 42 deletions

View File

@ -3466,48 +3466,6 @@ _mysqladmin()
} && } &&
complete -F _mysqladmin mysqladmin complete -F _mysqladmin mysqladmin
# gzip(1) completion
#
have gzip &&
_gzip()
{
local cur prev xspec helpopts
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
helpopts=`_parse_help gzip`
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$helpopts -2 -3 -4 -5 -6 -7 -8" \
-- "$cur" ) )
return 0
fi
local IFS=$'\t\n'
xspec="*.?(t)gz"
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --list || \
"$prev" == --test ]] && xspec="!"$xspec
[[ "$prev" == --force ]] && xspec=
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
[[ "$prev" == -*f* ]] && xspec=
elif [ "$prev" = '>' -o "$prev" = '>>' ]; then
xspec=
elif [ "$prev" = '<' ]; then
xspec=
fi
_expand || return 0
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
} &&
complete -F _gzip $filenames gzip
# bzip2(1) completion # bzip2(1) completion
# #
have bzip2 && have bzip2 &&

44
contrib/gzip Normal file
View File

@ -0,0 +1,44 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for gzip
have gzip &&
_gzip()
{
local cur prev xspec helpopts
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
helpopts=`_parse_help gzip`
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$helpopts -2 -3 -4 -5 -6 -7 -8" \
-- "$cur" ) )
return 0
fi
local IFS=$'\t\n'
xspec="*.?(t)gz"
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --list || \
"$prev" == --test ]] && xspec="!"$xspec
[[ "$prev" == --force ]] && xspec=
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
[[ "$prev" == -*f* ]] && xspec=
elif [ "$prev" = '>' -o "$prev" = '>>' ]; then
xspec=
elif [ "$prev" = '<' ]; then
xspec=
fi
_expand || return 0
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
} &&
complete -F _gzip $filenames gzip