From 0aa4456d5657c957eaf0c54f6eb24e58b9149d4b Mon Sep 17 00:00:00 2001 From: mapc Date: Sat, 30 Jun 2012 01:42:35 +0200 Subject: [PATCH 1/5] Add completion instructions for apt/aptitude commands --- plugins/debian/debian.plugin.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 39d3ef36a..22803ee1b 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -107,6 +107,20 @@ else ?not(~n`uname -r`))'\'' root' fi +# Completion ################################################################ + +# TODO: These definitions won't change between apt-get and uptitude automaticaly +compdef _apt aac="$apt_pref autoclean" +compdef _apt abd="$apt_pref build-dep" +compdef _apt ac="$apt_pref clean" +compdef _apt ad="$apt_pref update" +compdef _apt afu="$apt_pref update" +compdef _apt ag="$apt_pref upgrade" +compdef _apt ai="$apt_pref install" +compdef _apt ail="$apt_pref install" +compdef _apt ap="$apt_pref purge" +compdef _apt ar="$apt_pref remove" +compdef _apt ads="apt-get dselect-upgrade" # Misc. ##################################################################### # print all installed packages From 7d24f4cd407d61a17bd88157c594215ecc3b0bcd Mon Sep 17 00:00:00 2001 From: mapc Date: Sat, 30 Jun 2012 01:42:47 +0200 Subject: [PATCH 2/5] Use a static apt-get where only apt-get works --- plugins/debian/debian.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 22803ee1b..55e2be06c 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -56,7 +56,7 @@ if [[ $use_sudo -eq 1 ]]; then alias ar='sudo $apt_pref remove' # apt-get only - alias ads='sudo $apt_pref dselect-upgrade' + alias ads='sudo apt-get dselect-upgrade' # Install all .deb files in the current directory. # Warning: you will need to put the glob in single quotes if you use: From e3c87611fc75ff5149b13fdd84ee8c87c7c1d129 Mon Sep 17 00:00:00 2001 From: mapc Date: Sat, 30 Jun 2012 01:44:08 +0200 Subject: [PATCH 3/5] Add myself to the authors list --- plugins/debian/debian.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 55e2be06c..c556cb0b5 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -1,6 +1,7 @@ # Authors: # https://github.com/AlexBio # https://github.com/dbb +# https://github.com/Mappleconfusers # # Debian-related zsh aliases and functions for zsh From 5f37649508f6b6323e78249671d7897af8076886 Mon Sep 17 00:00:00 2001 From: mapc Date: Sat, 30 Jun 2012 04:44:26 +0200 Subject: [PATCH 4/5] Dynamicly generate completion functions to support changing apt_pref --- plugins/debian/debian.plugin.zsh | 45 +++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index c556cb0b5..b6f9fd2bf 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -110,18 +110,39 @@ fi # Completion ################################################################ -# TODO: These definitions won't change between apt-get and uptitude automaticaly -compdef _apt aac="$apt_pref autoclean" -compdef _apt abd="$apt_pref build-dep" -compdef _apt ac="$apt_pref clean" -compdef _apt ad="$apt_pref update" -compdef _apt afu="$apt_pref update" -compdef _apt ag="$apt_pref upgrade" -compdef _apt ai="$apt_pref install" -compdef _apt ail="$apt_pref install" -compdef _apt ap="$apt_pref purge" -compdef _apt ar="$apt_pref remove" -compdef _apt ads="apt-get dselect-upgrade" +# +# Registers a compdef for $1 that calls $apt_pref with the commands $2 +# To do that it creates a new completion function called _apt_pref_$2 +# +apt_pref_compdef() { + local f fb + f="_apt_pref_${2}" + + fb="function ${f}() { + shift words; + service=\"\$apt_pref\"; + 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. ##################################################################### # print all installed packages From 1b36c1beae21dafead692f83a099bdd69a0c6e50 Mon Sep 17 00:00:00 2001 From: mapc Date: Sat, 30 Jun 2012 05:37:10 +0200 Subject: [PATCH 5/5] Remove debug info --- plugins/debian/debian.plugin.zsh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index b6f9fd2bf..722b83c30 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -118,16 +118,13 @@ apt_pref_compdef() { local f fb f="_apt_pref_${2}" - fb="function ${f}() { + eval "function ${f}() { shift words; service=\"\$apt_pref\"; words=(\"\$apt_pref\" '$2' \$words); ((CURRENT++)) test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt }" - - eval "$fb" - echo "$fb" compdef "$f" "$1" }