/bash_completion.d/apt-show-versions
http://github.com/brinkman83/bashrc · #! · 51 lines · 46 code · 5 blank · 0 comment · 0 complexity · fa1d3d49e31d9ec2a7620bda126f75d1 MD5 · raw file
- #-*-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=( $(_comp_dpkg_installed_packages $cur) )
- 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=( $(_comp_dpkg_installed_packages $cur) )
- return 0
- fi
- }
- complete -F _apt_show_versions -o filenames apt-show-versions