summaryrefslogtreecommitdiff
path: root/completions/dpkg
diff options
context:
space:
mode:
Diffstat (limited to 'completions/dpkg')
-rw-r--r--completions/dpkg46
1 files changed, 22 insertions, 24 deletions
diff --git a/completions/dpkg b/completions/dpkg
index d14e5e3e..725542a7 100644
--- a/completions/dpkg
+++ b/completions/dpkg
@@ -8,11 +8,11 @@ _comp_dpkg_installed_packages()
} || {
_comp_dpkg_installed_packages()
{
- command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
+ command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
half-configured" \
-Ee "^Essential: yes" | \
- command grep "Package: $1" | cut -d\ -f2
+ awk "/Package: $1/ { print \$2 }" 2>/dev/null
}
}
@@ -24,11 +24,11 @@ _comp_dpkg_purgeable_packages()
} || {
_comp_dpkg_purgeable_packages()
{
- command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
+ command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
half-configured|config-files" \
-Ee "^Essential: yes" | \
- command grep "Package: $1" | cut -d\ -f2
+ awk "/Package: $1/ { print \$2 }" 2>/dev/null
}
}
@@ -39,8 +39,6 @@ _dpkg()
local cur prev words cword split
_init_completion -s || return
- _expand || return 0
-
local i=$cword
# find the last option flag
@@ -55,28 +53,28 @@ _dpkg()
-c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \
--contents|--info|--fsys-tarfile|--field|--control|--extract| \
--show)
- _filedir '?(u)deb'
- return 0
+ _filedir '?(u|d)deb'
+ return
;;
-b|--build)
_filedir -d
- return 0
+ return
;;
-s|-p|-l|--status|--print-avail|--list)
COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) )
- return 0
+ return
;;
-S|--search)
_filedir
- return 0
+ return
;;
-r|--remove)
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
- return 0
+ return
;;
-L|-P|--listfiles|--purge)
COMPREPLY=( $( _comp_dpkg_purgeable_packages "$cur" ) )
- return 0
+ return
;;
esac
@@ -98,25 +96,25 @@ _dpkg_reconfigure()
case $prev in
-f|--frontend)
- opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) )
- opt=( ${opt[@]##*/} )
- opt=( ${opt[@]%.pm} )
- COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) )
- return 0
- ;;
+ opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) )
+ opt=( ${opt[@]##*/} )
+ opt=( ${opt[@]%.pm} )
+ COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) )
+ return
+ ;;
-p|--priority)
- COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) )
- return 0
- ;;
+ COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) )
+ return
+ ;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only
- --help --showold --force --terse' -- "$cur" ) )
+ --help --showold --force --terse' -- "$cur" ) )
else
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
fi
} &&
complete -F _dpkg_reconfigure -o default dpkg-reconfigure
-# ex: ts=4 sw=4 et filetype=sh
+# ex: filetype=sh