summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Durrleman <dualmoo@gmail.com>2008-01-10 18:52:30 -0800
committerSaleem Abdulrasool <compnerd@compnerd.org>2008-01-10 20:16:55 -0800
commit7a927042ff1dd40ebdc444f79876d4e99d4938c7 (patch)
tree0e49f348ddfe32c1166aeb08ae693bf6c4fbf5f2
parentfix up authors (diff)
downloadzsh-completion-7a927042ff1dd40ebdc444f79876d4e99d4938c7.tar.gz
zsh-completion-7a927042ff1dd40ebdc444f79876d4e99d4938c7.tar.bz2
zsh-completion-7a927042ff1dd40ebdc444f79876d4e99d4938c7.zip
add completion for eselect
-rw-r--r--AUTHORS1
-rw-r--r--_eselect36
2 files changed, 37 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 66e123b..22b4a72 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
Baptiste Daroussin <baptiste.daroussin@gmail.com>
+David Durrleman <dualmoo@gmail.com>
oberyno <oberyno@gmail.com>
diff --git a/_eselect b/_eselect
new file mode 100644
index 0000000..faeba4e
--- /dev/null
+++ b/_eselect
@@ -0,0 +1,36 @@
+#compdef eselect
+#Author: David Durrleman
+#Contributor : Baptiste Daroussin <baptiste.daroussin@gmail.com>
+
+_eselect () {
+ local globopts sedcmd modnames modopts
+
+ globopts=(
+ "--no-colour[Disable coloured output]" \
+ "--no-color[Disable coloured output]"
+ )
+ modnames=(${${${(M)${(f)"$(eselect --no-color list-modules)"}## *}// */}// /})
+
+ if ((CURRENT == 2)); then
+ _arguments -s \
+ "$globopts[@]" \
+ "*:portage:_values 'eselect modules' \$modnames[@]" && return 0
+ elif ((CURRENT == 3)); then
+ if [[ $words[2] == --no-colour || $words[2] == --no-color ]]; then
+ _arguments -s \
+ "*:portage:_values 'eselect modules' \$modnames[@]" && return 0
+ elif (( $modnames[(I)$words[2]] )); then
+ modopts=(${${${(M)${(f)"$(eselect --no-color $words[2] usage)"}## *}// */}// /})
+ _arguments -s \
+ "*:portage:_values 'eselect $words[2] options' \$modopts[@]" && return 0
+ fi
+ elif ((CURRENT == 4)); then
+ if (( $modnames[(I)$words[3]] )); then
+ modopts=(${${${(M)${(f)"$(eselect --no-color $words[3] usage)"}## *}// */}// /})
+ _arguments -s \
+ "*:portage:_values 'eselect $words[3] options' \$modopts[@]" && return 0
+ fi
+ fi
+}
+
+_eselect "$@"