1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#-*-shell-script-*-
_have apt-show-versions &&
_apt_show_versions()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == --*=* ]]
then
prev="${cur%=*}"
cur="${cur##*=}"
else
prev="${COMP_WORDS[COMP_CWORD-1]}"
fi
opts="-a --allversions -b --brief -h --help -i --initialize -ld --list-dir"
opts="$opts -nh --nohold -p --package -r --regex -stf --status-file"
opts="$opts -u --upgradeable -v --verbose"
# Look for options needing an argument.
# The used completion functions are defined in /etc/bash_completion.
case "$prev" in
-ld|--list-dir)
_filedir -d
return 0
;;
-p|--package)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" 2> /dev/null ) )
return 0
;;
-stf|--status-file)
_filedir
return 0
;;
*)
;;
esac
# Look for options without an argument.
if [[ "$cur" == -* ]]
then
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
return 0
else
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" 2> /dev/null ) )
return 0
fi
}
complete -F _apt_show_versions -o filenames apt-show-versions
|