Hi,

On Tue, 24 Feb 2015 14:50:19 +0100, Sebastian Schulze wrote:
> Unfortunately, i cannot access the links to the patch.
> Is it possible to either include this fix or make the patch available 
> somewhere?

I am attaching Michael's original patch here.

--
Dmitry Shachnev
From d8830acfe154aaa2fd60710da5d0fb85dbf2f58c Mon Sep 17 00:00:00 2001
From: Michael Vogt <m...@debian.org>
Date: Fri, 11 Apr 2014 20:07:58 +0200
Subject: [PATCH] add bash completions for the new "apt" command

---
 completions/apt | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 completions/apt

diff --git a/completions/apt b/completions/apt
new file mode 100644
index 0000000..9929bf7
--- /dev/null
+++ b/completions/apt
@@ -0,0 +1,95 @@
+# 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=("install" "remove" "purge" "show" "list"
+                    "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|full-upgrade)
+                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)
+                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
+                ;;
+            install|show|list)
+                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+                    2> /dev/null ) )
+                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
-- 
1.9.1

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Bash-completion-devel mailing list
Bash-completion-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel

Reply via email to