#/usr/bin/env bash
_foo()
{
COMPREPLY=($(compgen -W "help configure run"))
}
complete -F _foo foo
Given a command foo
that has subcommands foo [configure/show] [options]
#/usr/bin/env bash
# bash-completion.bash
# source ./bash-completion.bash
_foo()
{
local cur prev
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ${COMP_CWORD} in
1)
COMPREPLY=($(compgen -W "configure show" -- ${cur}))
;;
2)
case ${prev} in
configure)
COMPREPLY=($(compgen -W "CM DSP NPU" -- ${cur}))
;;
show)
COMPREPLY=($(compgen -W "some other args" -- ${cur}))
;;
esac
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _foo foo