From 7f1614554c421905a946dff3b3082ed6af7d468c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 8 Jan 2016 21:36:53 +0100 Subject: Install bash completion with correct name Move the completion to completions/bash/apt and install all bash completions from completions/bash. Gbp-Dch: ignore --- completions/bash/apt | 107 +++++++++++++++++++++++++++++++++++++++++++++ debian/apt.bash-completion | 107 --------------------------------------------- debian/apt.install.in | 2 +- 3 files changed, 108 insertions(+), 108 deletions(-) create mode 100644 completions/bash/apt delete mode 100644 debian/apt.bash-completion diff --git a/completions/bash/apt b/completions/bash/apt new file mode 100644 index 000000000..d7104ec5a --- /dev/null +++ b/completions/bash/apt @@ -0,0 +1,107 @@ +# Debian apt(8) completion -*- shell-script -*- + +_apt() +{ + local sourcesdir="/etc/apt/sources.list.d" + local cur prev words cword + _init_completion || return + + # see if the user selected a command already + local COMMANDS=( + "list" + "search" + "show" + "install" "remove" "purge" "autoremove" + "update" + "upgrade" "full-upgrade" "dist-upgrade" + "edit-sources" + "help") + + local command i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then + command=${words[i]} + break + fi + done + + # supported options per command + if [[ "$cur" == -* ]]; then + case $command in + install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove) + COMPREPLY=( $( compgen -W '--show-progress + --fix-broken --purge --verbose-versions --auto-remove + --simulate --dry-run + --download + --fix-missing + --fix-policy + --ignore-hold + --force-yes + --trivial-only + --reinstall --solver' -- "$cur" ) ) + return 0 + ;; + update) + COMPREPLY=( $( compgen -W '--list-cleanup + ' -- "$cur" ) ) + return 0 + ;; + list) + COMPREPLY=( $( compgen -W '--installed --upgradable + --manual-installed + -v --verbose + -a --all-versions + ' -- "$cur" ) ) + return 0 + ;; + show) + COMPREPLY=( $( compgen -W '-a --all-versions + ' -- "$cur" ) ) + return 0 + ;; + esac + fi + + # specific command arguments + if [[ -n $command ]]; then + case $command in + remove|purge|autoremove) + if [[ -f /etc/debian_version ]]; then + # Debian system + COMPREPLY=( $( \ + _xfunc dpkg _comp_dpkg_installed_packages $cur ) ) + else + # assume RPM based + _xfunc rpm _rpm_installed_packages + fi + return 0 + ;; + show|list) + COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ + 2> /dev/null ) ) + return 0 + ;; + install) + COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ + 2> /dev/null ) ) + _filedir "*.deb" + return 0 + ;; + edit-sources) + COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \ + -- "$cur" ) ) + return 0 + ;; + esac + fi + + # no command yet, show what commands we have + if [ "$command" = "" ]; then + COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) ) + fi + + return 0 +} && +complete -F _apt apt + +# ex: ts=4 sw=4 et filetype=sh diff --git a/debian/apt.bash-completion b/debian/apt.bash-completion deleted file mode 100644 index d7104ec5a..000000000 --- a/debian/apt.bash-completion +++ /dev/null @@ -1,107 +0,0 @@ -# Debian apt(8) completion -*- shell-script -*- - -_apt() -{ - local sourcesdir="/etc/apt/sources.list.d" - local cur prev words cword - _init_completion || return - - # see if the user selected a command already - local COMMANDS=( - "list" - "search" - "show" - "install" "remove" "purge" "autoremove" - "update" - "upgrade" "full-upgrade" "dist-upgrade" - "edit-sources" - "help") - - local command i - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then - command=${words[i]} - break - fi - done - - # supported options per command - if [[ "$cur" == -* ]]; then - case $command in - install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove) - COMPREPLY=( $( compgen -W '--show-progress - --fix-broken --purge --verbose-versions --auto-remove - --simulate --dry-run - --download - --fix-missing - --fix-policy - --ignore-hold - --force-yes - --trivial-only - --reinstall --solver' -- "$cur" ) ) - return 0 - ;; - update) - COMPREPLY=( $( compgen -W '--list-cleanup - ' -- "$cur" ) ) - return 0 - ;; - list) - COMPREPLY=( $( compgen -W '--installed --upgradable - --manual-installed - -v --verbose - -a --all-versions - ' -- "$cur" ) ) - return 0 - ;; - show) - COMPREPLY=( $( compgen -W '-a --all-versions - ' -- "$cur" ) ) - return 0 - ;; - esac - fi - - # specific command arguments - if [[ -n $command ]]; then - case $command in - remove|purge|autoremove) - if [[ -f /etc/debian_version ]]; then - # Debian system - COMPREPLY=( $( \ - _xfunc dpkg _comp_dpkg_installed_packages $cur ) ) - else - # assume RPM based - _xfunc rpm _rpm_installed_packages - fi - return 0 - ;; - show|list) - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ - 2> /dev/null ) ) - return 0 - ;; - install) - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ - 2> /dev/null ) ) - _filedir "*.deb" - return 0 - ;; - edit-sources) - COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \ - -- "$cur" ) ) - return 0 - ;; - esac - fi - - # no command yet, show what commands we have - if [ "$command" = "" ]; then - COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) ) - fi - - return 0 -} && -complete -F _apt apt - -# ex: ts=4 sw=4 et filetype=sh diff --git a/debian/apt.install.in b/debian/apt.install.in index e2bedcca7..4b7330340 100644 --- a/debian/apt.install.in +++ b/debian/apt.install.in @@ -4,4 +4,4 @@ bin/methods/* usr/lib/apt/methods/ scripts/dselect/* usr/lib/dpkg/methods/apt/ usr/share/locale/*/*/apt.mo bin/libapt-private.so.* usr/lib/@DEB_HOST_MULTIARCH@/ -../debian/apt.bash-completion /usr/share/bash-completion/completions/ +../completions/bash/* /usr/share/bash-completion/completions/ -- cgit v1.2.3