102 lines
2.5 KiB
Plaintext
Raw Normal View History

# xz(1) completion
have xz || have pxz &&
_xz()
{
local cur prev words cword
_init_completion -n = || return
local split=false
_split_longopt && split=true
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--compress --decompress --test --list \
2011-03-21 19:42:22 +02:00
--keep --force --stdout --no-sparse --suffix --files --files0 \
--format --check -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 --extreme --memory \
--lzma1 --lzma2 --x86 --powerpc --ia64 --arm --armthumb --sparc \
2011-03-21 19:42:22 +02:00
--delta --quiet --verbose --no-warn --robot --info-memory --help \
--long-help --version' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
local xspec="*.@(xz|lzma|txz|tlz)"
case $prev in
--decompress|--list|--test|-!(-*)[dlt]*)
2009-10-04 19:42:50 +02:00
xspec="!"$xspec
;;
--files|--files0)
_filedir
return 0
;;
-C|--check)
2011-03-21 19:42:22 +02:00
COMPREPLY=( $( compgen -W 'crc32 crc64 sha256 none' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-F|--format)
COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) )
return 0
;;
-M|--memory|-S|--suffix|--delta|--lzma1|--lzma2)
# argument required but no completions available
return 0
;;
2011-03-21 19:42:22 +02:00
-h|--help|-H|--long-help|-V|--version|--info-memory)
2009-10-04 19:42:50 +02:00
# all other arguments are noop with these
return 0
;;
esac
2009-10-04 19:42:50 +02:00
$split && return 0
2009-10-04 19:42:50 +02:00
_expand || return 0
local IFS=$'\n'
compopt -o filenames
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
2011-03-21 19:35:30 +02:00
complete -F _xz xz pxz
# xzdec(1) completion
#
have xzdec &&
_xzdec()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
2011-03-21 19:42:22 +02:00
COMPREPLY=( $( compgen -W '--memory --quiet --help --version' \
-- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
2009-10-04 19:42:50 +02:00
local split=false
_split_longopt && split=true
case $prev in
2009-10-04 19:42:50 +02:00
-M|--memory)
# argument required but no completions available
return 0
;;
-h|--help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
2009-10-04 19:42:50 +02:00
$split && return 0
2010-11-01 19:08:01 +02:00
_filedir xz # no lzma support here as of xz 4.999.9beta
} &&
complete -F _xzdec xzdec
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh