56 lines
1.5 KiB
Plaintext
Raw Normal View History

# xz(1) completion -*- shell-script -*-
_xz()
{
local cur prev words cword split
_init_completion -s || return
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|--memlimit|--memlimit-compress|--memlimit-decompress|--memory|\
-S|--suffix|--delta|--lzma1|--lzma2)
2009-10-04 19:42:50 +02:00
# 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
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \
-- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
fi
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
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh