Suggested patch for /etc/bash_completion.d/gentoo: (@ line 591 onwards) _openglupdate() { local cur opts + # opts already defined but not used + opts=\'$(ls /usr/lib/opengl)\' COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} numwords=${#COMP_WORDS[*]} if [ ${numwords} -gt 2 ]; then return 0 fi + COMPREPLY=($(compgen -W $opts $cur)) -# COMPREPLY=($(compgen -W 'nvidia xfree' $cur)) COMPREPLY=($(echo " ${COMP_WORDS[@]}" | \ (while read -d ' ' i; do [ "$i" == "" ] && continue # flatten array with spaces on either side, # otherwise we cannot grep on word # boundaries of first and last word COMPREPLY=" ${COMPREPLY[@]} " # remove word from list of completions COMPREPLY=( ${COMPREPLY/ $i / }) done echo ${COMPREPLY[@]}))) return 0 } complete -F _openglupdate opengl-update
I'll use the following line since $opts would be only used once And external commands like 'ls' shouldn't be used in bash-completion if theres a simple solution using internal bash functions. COMPREPLY=($(compgen -W "$(for i in /usr/lib/opengl/*; do echo ${i##*/}; done)" $cur))
I think this would do the job much simpler: _openglupdate() { local cur COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} if [ ${#COMP_WORDS[*]} -le 2 ]; then COMPREPLY=($(compgen -W "$(for i in /usr/lib/opengl/*; do [ -d "$i" ] && echo ${i##*/}; done)" $cur)) fi return 0 } complete -F _openglupdate opengl-update
Function changed in CVS