52 lines
1.3 KiB
Bash
52 lines
1.3 KiB
Bash
#-*-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
|