diff options
author | Michael Vogt <mvo@ubuntu.com> | 2016-01-02 21:18:47 +0100 |
---|---|---|
committer | Michael Vogt <mvo@ubuntu.com> | 2016-01-02 21:44:46 +0100 |
commit | bd8274311db48fdcc78456c17c2d59497b96cc2f (patch) | |
tree | 38b661ff4b2a15928f026cbec71b73d9241554d4 /debian | |
parent | 73d52d65816491c0dd8815f393c238f599fea21e (diff) | |
download | apt-bd8274311db48fdcc78456c17c2d59497b96cc2f.tar.gz |
Add bash-completion support for the "apt" command
The apt bash-completion support was submited to the bash-completion
package as a patch in May 2014. It is still not included to this
date and because it is an important feature for many users it is
now part of apt until the bash-completion package is mantained
more actively again.
Note that the "Relaces" line is only required for Ubuntu it will
have no effect on Debian.
Closes: #747094
Diffstat (limited to 'debian')
-rw-r--r-- | debian/apt.bash-completion | 107 | ||||
-rw-r--r-- | debian/apt.dirs | 1 | ||||
-rw-r--r-- | debian/apt.install.in | 1 | ||||
-rw-r--r-- | debian/control | 2 |
4 files changed, 110 insertions, 1 deletions
diff --git a/debian/apt.bash-completion b/debian/apt.bash-completion new file mode 100644 index 000000000..d7104ec5a --- /dev/null +++ b/debian/apt.bash-completion @@ -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.dirs b/debian/apt.dirs index 6d492a30f..e4bb2c824 100644 --- a/debian/apt.dirs +++ b/debian/apt.dirs @@ -15,3 +15,4 @@ var/lib/apt/mirrors/partial var/lib/apt/periodic var/log/apt usr/share/bug/apt +usr/share/bash-completion/completions/
\ No newline at end of file diff --git a/debian/apt.install.in b/debian/apt.install.in index 9c9489572..e2bedcca7 100644 --- a/debian/apt.install.in +++ b/debian/apt.install.in @@ -4,3 +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/ diff --git a/debian/control b/debian/control index f2121e9f0..bb5bf87ae 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Testsuite: autopkgtest Package: apt Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${apt:keyring}, gpgv | gpgv2, gnupg | gnupg2, adduser -Replaces: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~), sun-java6-jdk (>> 0), sun-java5-jdk (>> 0), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~) +Replaces: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~), sun-java6-jdk (>> 0), sun-java5-jdk (>> 0), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), bash-completion (<< 1:2.1-4.2+fakesync1) Breaks: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~), sun-java6-jdk (>> 0), sun-java5-jdk (>> 0), openjdk-6-jdk (<< 6b24-1.11-0ubuntu1~), apt-utils (<< 1.1.3) Suggests: aptitude | synaptic | wajig, dpkg-dev (>= 1.17.2), apt-doc, python-apt Description: commandline package manager |