[pacman-dev] [PATCH] zsh_completion: Add proper completion for --ignore and --ignoregroup
Nezmer
Nezmer at allurelinux.org
Tue Dec 15 13:45:55 EST 2009
This patch provides proper comma-separated completions for --ignore and --ignoregroup
Signed-off-by: Nezmer <Nezmer at allurelinux.org>
---
contrib/zsh_completion | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/contrib/zsh_completion b/contrib/zsh_completion
index 2f43d9b..b27261f 100644
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -86,9 +86,9 @@ _pacman_opts_sync_modifiers=(
'-w[Download packages only]'
'-y[Download fresh package databases]'
'*--ignore[Ignore a package upgrade]:package:
- _pacman_completions_all_packages'
- '*--ignoregroup[Ignore a group upgrade]:package group:
- _pacman_completions_all_groups'
+ _pacman_completions_ignore_packages'
+ '*--ignoregroup[Ignore a group upgrade]:group:
+ _pacman_completions_ignore_groups'
'--asdeps[Install packages as non-explicitly installed]'
'--asexplicit[Install packages as explicitly installed]'
)
@@ -240,6 +240,29 @@ _pacman_completions_all_packages() {
fi
}
+# provides comma-separated completions for packages available from repositories
+# to be used with --ignore
+_pacman_completions_ignore_packages() {
+ local -a cmd packages repositories packages_long
+
+ repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
+ typeset -U repositories
+ packages_long=(/var/lib/pacman/sync/${^repositories}/*(/))
+ packages=(${(o)${${packages_long/\/var\/lib\/pacman\/sync\//}#*/}%-*-*} )
+ typeset -U packages
+ _wanted packages expl "packages" _values -s "," compadd - "${(@)packages}"
+}
+
+# provides comma-separated completions for package groups to be used
+# with --ignoregroup
+_pacman_completions_ignore_groups() {
+ local -a cmd groups
+ _pacman_get_command
+ groups=($(pacman -Sg))
+ typeset -U groups
+ _wanted groups expl "groups" _values -s "," compadd - "${(@)groups}"
+}
+
# provides completions for package groups
_pacman_completions_installed_groups() {
local -a cmd groups
--
1.6.5.6
More information about the pacman-dev
mailing list