diff options
-rw-r--r-- | completions/dpkg | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/completions/dpkg b/completions/dpkg index 247171c5..5794c2e1 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -10,6 +10,22 @@ _comp_dpkg_installed_packages() { command grep -A 1 "Package: $1" /var/lib/dpkg/status | \ command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ + half-configured" \ + -Ee "^Essential: yes" | \ + command grep "Package: $1" | cut -d\ -f2 +} +} + +_have grep-status && { +_comp_dpkg_purgeable_packages() +{ + grep-status -P -e '^ruby' -a -FStatus 'install ok installed' -o -FStatus 'deinstall ok config-files' -n -s Package +} +} || { +_comp_dpkg_purgeable_packages() +{ + command grep -A 1 "Package: $1" /var/lib/dpkg/status | \ + command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ half-configured|config-files" \ -Ee "^Essential: yes" | \ command grep "Package: $1" | cut -d\ -f2 @@ -54,10 +70,14 @@ _dpkg() _filedir return 0 ;; - -r|-L|-P|--remove|--purge|--listfiles) + -r|--remove) COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) return 0 ;; + -L|-P|--listfiles|--purge) + COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) ) + return 0 + ;; esac $split && return |