6

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?

1 Answers1

5

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
muru
  • 72,889
  • Two issues: 1) the output of "complete -p" is not readily usable; 2) the existence of "on-demand" completion by completion loader ("complete -D") complicates things, because we must evaluate this "complete -D" if we want to search for completion more exhaustively. – Gerry Lufwansa Dec 09 '17 at 11:02
  • @GerryLufwansa not usable how? Also, edit clarifications into your question, please – muru Dec 09 '17 at 11:10
  • The output of complete -p wget is currently bash: complete: wget: no completion specification (bash 5.0.3(1)-release, and there is indeed valid completion for wget). – Adam Katz Nov 08 '19 at 16:23