#compdef eselect # ZSH completion function for eselect # Author: David Durrleman _modactions () { local modactions modactions=(help usage version) # taken from /usr/share/bash-completion/eselect sedcmd="sed -n -e s/^[[:space:]]\+.*1m\([^[:space:]][[:alnum:]-]\+\).*[[:space:]]\+.*$/\1/p" modactions=($(eselect $1 usage | ${=sedcmd}) $modactions) echo $modactions } _eselect () { local modfiles mods globargs modactions modfiles=(/usr/share/eselect/modules/*(:t)) mods=(help list-modules usage version ${modfiles%\.eselect}) globargs=("--no-colour[Disable coloured output]") if ((CURRENT == 2)); then _arguments -s \ "$globargs[@]" \ "*:portage:_values 'eselect modules' \$mods[@]" && return 0 elif ((CURRENT == 3)); then if [[ $words[2] == --no-colour ]]; then _arguments -s \ "*:portage:_values 'eselect modules' \$mods[@]" && return 0 elif (( $mods[(I)$words[2]] )); then modactions=($(_modactions $words[2])) _arguments -s \ "*:portage:_values 'eselect $words[2] options' \$modactions[@]" && return 0 fi elif ((CURRENT == 4)); then if (( $mods[(I)$words[3]] )); then modactions=($(_modactions $words[3])) _arguments -s \ "*:portage:_values 'eselect $words[3] options' \$modactions[@]" && return 0 fi fi } _eselect "$@"