2009-05-17 22:02:37 +02:00
|
|
|
# bash completion for bzip2
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have bzip2 || have pbzip2 || return
|
|
|
|
|
2009-05-17 22:02:37 +02:00
|
|
|
_bzip2()
|
|
|
|
{
|
2011-04-20 14:22:23 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-01-18 19:21:08 +02:00
|
|
|
|
|
|
|
case $prev in
|
|
|
|
-b|-h|--help|-p)
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-10-04 19:42:50 +02:00
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-04-27 22:22:49 +03:00
|
|
|
local helpopts=$( _parse_help "$1" )
|
2010-01-18 19:21:08 +02:00
|
|
|
COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \
|
2010-01-18 19:11:28 +02:00
|
|
|
-- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2011-04-20 14:22:23 +03:00
|
|
|
local IFS=$'\n' xspec="*.bz2"
|
2009-10-04 19:42:50 +02:00
|
|
|
|
|
|
|
if [[ "$prev" == --* ]]; then
|
|
|
|
[[ "$prev" == --decompress || \
|
|
|
|
"$prev" == --list || \
|
|
|
|
"$prev" == --test ]] && xspec="!"$xspec
|
|
|
|
[[ "$prev" == --compress ]] && xspec=
|
|
|
|
elif [[ "$prev" == -* ]]; then
|
|
|
|
[[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
|
|
|
|
[[ "$prev" == -*z* ]] && xspec=
|
|
|
|
fi
|
|
|
|
|
|
|
|
_expand || return 0
|
|
|
|
|
2011-04-21 12:33:05 +03:00
|
|
|
compopt -o filenames
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
|
|
|
|
$( compgen -d -- "$cur" ) )
|
2009-05-17 22:02:37 +02:00
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _bzip2 bzip2 pbzip2
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|