have epic && _epic() { local cur prev opts base COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" # # The basic options we'll complete. # opts="showinfo showlist install uninstall help" case "${prev}" in showinfo | install | uninstall) local epis=$(epic showlist) if [[ $epis == *"List of all epi"* ]];then epis=${epis//"[EPIC]: List of all epi files that can be installed with EPIC: "/} epis=${epis//,/} COMPREPLY=( $(compgen -W "${epis}" -- ${cur}) ) else COMPREPLY=($(compgen -W "${opts}" -- ${cur})) fi return 0 ;; *) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; esac } [ "$have" ] && complete -F _epic epic