Completing a command like another command in bash

autocomplete

Let's say I'm creating a wrapper for the Unix program wget called wget-hip. I want wget-hip to get the same shell completion rule as wget because they both happen to have the same command-line options.

So if wget has this completion rule:

complete -F _wget wget

or:

complete -C _wget wget

then I want:

complete -F _wget wget-hip

or:

complete -C _wget wget-hip

Is there a proper way to do this?

Best Answer

The -p option might be of use. From the bash manual:

If the -p option is supplied, or if no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input.

So, perhaps:

$(complete -p wget)-hip