Here goes:
function _command() {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
if [ "$COMP_CWORD" -ge "2" ]; then
COMPREPLY=($( compgen -W '$(pwd)' -- "$cur" ) )
else
COMPREPLY=($( compgen -W "arg1 arg2" -- "$cur" ) )
fi
}
complete -F _command command
This works well, so long as I source it.
What if I want it to auto-complete both outputs of pwd and some other arbitrary command, say hostname? What if I also wanted it to auto-complete on any file path?