have zerocenter-report && _zerocenter-report() { local cur prev opts base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" # # The basic options we'll complete. # opts="getlist getzmdinfo help" case "${prev}" in getlist) local groups="-v --verbose admins teachers students all" COMPREPLY=( $(compgen -W "${groups}" -- ${cur}) ) return 0 ;; getzmdinfo) local names=$(ls /usr/share/zero-center/applications | grep .app | sed {s/".app"/""/} ) COMPREPLY=( $(compgen -W "${names}" -- ${cur}) ) return 0 ;; *) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; esac } [ "$have" ] && complete -F _zerocenter-report zerocenter-report