mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 21:51:05 +01:00
Dynamicly generate completion functions to support changing apt_pref
This commit is contained in:
parent
e3c87611fc
commit
5f37649508
1 changed files with 33 additions and 12 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue