#!/bin/bash

_bash_autocomplete() {
     local cur opts
     COMPREPLY=()
     cur="${COMP_WORDS[COMP_CWORD]}"
     opts=$( "${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion )
     COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
     return 0
}

PROGS=("bluemix" "bx" "ibmcloud")
for p in "${PROGS[@]}";
do
    complete -o default -F _bash_autocomplete "$p"
done
