I defined a function alias for a command: aa and I defined a _complete_aa function which is used as a suggestion for the aa command via complete -F _complete_aa aa (See code below)
aa(){
anothercommand ${@}
}
_complete_aa(){
COMPREPLY=($(compgen -W "clean build start" "${COMP_WORDS[1]}"))
}
complete -F _complete_aa aa
When I use the function I have an unexpected behavior:
When I type aa cle and press TAB the prompt correctly completes my input into aa clean
But, when I type aa clean bui and press TAB, the prompt completes my inuput into aa clean clean, while I expect it should change into aa clean build.
I guess my error is in the below completion function, Which does not take care of the index of the current word under completion.
_complete_aa(){
COMPREPLY=($(compgen -W "clean build start" "${COMP_WORDS[1]}"))
}
Question: how I should change the body of the _complete_aa function so that I get completion of the current word into clean build start for each new option/parameter I am typing ?