diff options
Diffstat (limited to 'completions/apt-get')
-rw-r--r-- | completions/apt-get | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/completions/apt-get b/completions/apt-get index 9c88fe60..4aee2639 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -6,28 +6,30 @@ _apt_get() _init_completion -n ':=' || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download|changelog) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then case $special in - remove|autoremove|purge) + remove | autoremove | purge) if [[ -f /etc/debian_version ]]; then # Debian system - COMPREPLY=( $(\ - _xfunc dpkg _comp_dpkg_installed_packages $cur) ) + COMPREPLY=($( + _xfunc dpkg _comp_dpkg_installed_packages $cur + )) else # assume RPM based _xfunc rpm _rpm_installed_packages fi ;; source) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) $(compgen -W "$(apt-cache dumpavail | - awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(compgen -W "$(apt-cache dumpavail | + awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur")) ;; install) if [[ $cur == */* ]]; then @@ -36,42 +38,46 @@ _apt_get() elif [[ $cur == *=* ]]; then package="${cur%%=*}" cur="${cur#*=}" - COMPREPLY=($(IFS=$'\n' compgen -W "$( \ - apt-cache --no-generate madison "$package" 2>/dev/null | \ - while IFS=' |' read -r _ version _; do - echo "$version" - done )" \ - -- "$cur")) + COMPREPLY=($(IFS=$'\n' compgen -W "$( + apt-cache --no-generate madison "$package" 2>/dev/null | + while IFS=' |' read -r _ version _; do + echo "$version" + done + )" \ + -- "$cur")) __ltrim_colon_completions "$cur" return fi ;;& + build-dep) + _filedir -d + [[ $cur != */* ]] || return + ;;& *) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) ) + COMPREPLY+=($(_xfunc apt-cache _apt_cache_packages)) ;; esac return fi case $prev in - --help|--version|--option|-!(-*)[hvo]) + --help | --version | --option | -!(-*)[hvo]) return ;; - --config-file|-!(-*)c) + --config-file | -!(-*)c) _filedir return ;; - --target-release|--default-release|-!(-*)t) - COMPREPLY=( $(compgen -W "$(apt-cache policy | command sed -ne \ + --target-release | --default-release | -!(-*)t) + COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \ 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \ - -- "$cur") ) + -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-install-recommends --install-suggests + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-install-recommends --install-suggests --download-only --fix-broken --ignore-missing --fix-missing --no-download --quiet --simulate --just-print --dry-run --recon --no-act --yes --assume-yes --assume-no --no-show-upgraded @@ -84,15 +90,15 @@ _apt_get() --diff-only --dsc-only --tar-only --arch-only --indep-only --allow-unauthenticated --no-allow-insecure-repositories --allow-releaseinfo-change --show-progress --with-source --help - --version --config-file --option' -- "$cur") ) + --version --config-file --option' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade dist-upgrade + COMPREPLY=($(compgen -W 'update upgrade dist-upgrade dselect-upgrade install remove purge source build-dep check download clean autoclean autoremove changelog indextargets' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _apt_get apt-get + complete -F _apt_get apt-get # ex: filetype=sh |