summaryrefslogtreecommitdiff
path: root/completions/aptitude
diff options
context:
space:
mode:
Diffstat (limited to 'completions/aptitude')
-rw-r--r--completions/aptitude39
1 files changed, 16 insertions, 23 deletions
diff --git a/completions/aptitude b/completions/aptitude
index c00ad40e..1afd738d 100644
--- a/completions/aptitude
+++ b/completions/aptitude
@@ -1,7 +1,6 @@
-# Debian aptitude(1) completion
+# Debian aptitude(1) completion -*- shell-script -*-
-have aptitude && {
-have grep-status && {
+_have grep-status && {
_comp_dpkg_hold_packages()
{
grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
@@ -16,11 +15,10 @@ _comp_dpkg_hold_packages()
_aptitude()
{
- local cur dashoptions prev special i
-
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
+ local cur prev words cword
+ _init_completion || return
+ local dashoptions
dashoptions='-S -u -i -h --help --version -s --simulate -d \
--download-only -P --prompt -y --assume-yes -F \
--display-format -O --sort -w --width -f -r -g \
@@ -28,25 +26,27 @@ _aptitude()
--target-release -V --show-versions -D --show-deps\
-Z -v --verbose --purge-unused --schedule-only'
- for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
- if [[ ${COMP_WORDS[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag) ]]; then
- special=${COMP_WORDS[i]}
+ local special i
+ for (( i=0; i < ${#words[@]}-1; i++ )); do
+ if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then
+ special=${words[i]}
fi
#exclude some mutually exclusive options
- [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
- [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
+ [[ ${words[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
+ [[ ${words[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
done
if [[ -n "$special" ]]; then
case $special in
install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \
download|show|changelog|why|why-not|build-dep|add-user-tag| \
- remove-user-tag)
+ remove-user-tag|versions)
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0
;;
purge|remove|reinstall|forbid-version)
- COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
+ COMPREPLY=( \
+ $( _xfunc dpkg _comp_dpkg_installed_packages "$cur" ) )
return 0
;;
unhold)
@@ -81,18 +81,11 @@ _aptitude()
hold unhold purge markauto unmarkauto why why-not \
dist-upgrade full-upgrade download search show \
forbid-version changelog keep-all build-dep \
- add-user-tag remove-user-tag' -- "$cur" ) )
+ add-user-tag remove-user-tag versions' -- "$cur" ) )
fi
return 0
-}
+} &&
complete -F _aptitude -o default aptitude
-}
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh