Dynamicly generate completion functions to support changing apt_pref

This commit is contained in:
mapc 2012-06-30 04:44:26 +02:00
parent e3c87611fc
commit 5f37649508

View file

@ -110,18 +110,39 @@ fi
# Completion ################################################################ # Completion ################################################################
# TODO: These definitions won't change between apt-get and uptitude automaticaly #
compdef _apt aac="$apt_pref autoclean" # Registers a compdef for $1 that calls $apt_pref with the commands $2
compdef _apt abd="$apt_pref build-dep" # To do that it creates a new completion function called _apt_pref_$2
compdef _apt ac="$apt_pref clean" #
compdef _apt ad="$apt_pref update" apt_pref_compdef() {
compdef _apt afu="$apt_pref update" local f fb
compdef _apt ag="$apt_pref upgrade" f="_apt_pref_${2}"
compdef _apt ai="$apt_pref install"
compdef _apt ail="$apt_pref install" fb="function ${f}() {
compdef _apt ap="$apt_pref purge" shift words;
compdef _apt ar="$apt_pref remove" service=\"\$apt_pref\";
compdef _apt ads="apt-get dselect-upgrade" words=(\"\$apt_pref\" '$2' \$words);
((CURRENT++))
test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
}"
eval "$fb"
echo "$fb"
compdef "$f" "$1"
}
apt_pref_compdef aac "autoclean"
apt_pref_compdef abd "build-dep"
apt_pref_compdef ac "clean"
apt_pref_compdef ad "update"
apt_pref_compdef afu "update"
apt_pref_compdef ag "upgrade"
apt_pref_compdef ai "install"
apt_pref_compdef ail "install"
apt_pref_compdef ap "purge"
apt_pref_compdef ar "remove"
apt_pref_compdef ads "dselect-upgrade"
# Misc. ##################################################################### # Misc. #####################################################################
# print all installed packages # print all installed packages