c9dd778ec07a890b71f652f92202b6a4dc9b9c27

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1201 from koraa/pull_req_debian

Fix Debian Plugin Auto Completion

Diff

 1diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
 2index b51d0cd37c25f9ac47fc37f23d983cab40f5a963..1e15487ba4768d72b0edfbc3deb4496de888278e 100644
 3--- a/plugins/debian/debian.plugin.zsh
 4+++ b/plugins/debian/debian.plugin.zsh
 5@@ -1,6 +1,7 @@
 6 # Authors:
 7 # https://github.com/AlexBio
 8 # https://github.com/dbb
 9+# https://github.com/Mappleconfusers
10 #
11 # Debian-related zsh aliases and functions for zsh
12 
13@@ -56,7 +57,7 @@ if [[ $use_sudo -eq 1 ]]; then
14     alias ar='sudo $apt_pref remove'
15 
16     # apt-get only
17-    alias ads='sudo $apt_pref dselect-upgrade'
18+    alias ads='sudo apt-get dselect-upgrade'
19 
20     # Install all .deb files in the current directory.
21     # Warning: you will need to put the glob in single quotes if you use:
22@@ -109,6 +110,38 @@ else
23         ?not(~n`uname -r`))'\'' root'
24 fi
25 
26+# Completion ################################################################
27+
28+#
29+# Registers a compdef for $1 that calls $apt_pref with the commands $2
30+# To do that it creates a new completion function called _apt_pref_$2
31+#
32+apt_pref_compdef() {
33+    local f fb
34+    f="_apt_pref_${2}"
35+
36+    eval "function ${f}() {
37+        shift words; 
38+	service=\"\$apt_pref\"; 
39+	words=(\"\$apt_pref\" '$2' \$words); 
40+	((CURRENT++))
41+	test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
42+    }"
43+
44+    compdef "$f" "$1"
45+}
46+
47+apt_pref_compdef aac "autoclean"
48+apt_pref_compdef abd "build-dep"
49+apt_pref_compdef ac  "clean"
50+apt_pref_compdef ad  "update"
51+apt_pref_compdef afu "update"
52+apt_pref_compdef ag  "upgrade"
53+apt_pref_compdef ai  "install"
54+apt_pref_compdef ail "install"
55+apt_pref_compdef ap  "purge"
56+apt_pref_compdef ar  "remove"
57+apt_pref_compdef ads "dselect-upgrade"
58 
59 # Misc. #####################################################################
60 # print all installed packages