magic-wormhole
magic-wormhole copied to clipboard
shell completion via `wormhole completion bash/fish/zsh`
it'd be better to embed the completion script in the wormhole command, versus as separate .bash, .fish, .zsh files.
That way, I can do something like below in the init script:
source <(kubectl completion bash)
source <($HOME/.local/python3/bin/pip completion --bash)
source <(wormhole completion bash)
Can you express this as a PR? (I don't use it this way so not sure how to test etc)
Actually, I'd suggest this is the wrong way to do things. If you do source <(wormhole completion bash) then, every time you launch a bash prompt, bash has to invoke wormhole, wait for wormhole to work out what you meant and print the completion script to stdout, then bash parses that completion script.
You could optimise that with something like:
if [ ! -f wormhole.completion ]; then
wormhole completion bash > wormhole.completion
fi
source wormhole.completion
(which effectively caches the result of calling wormhole completion bash to disk), but then how is that any better than the existing solution?
This appears done from the Makefile: https://github.com/magic-wormhole/magic-wormhole/blob/master/Makefile#L19
feel free to reopen for more discussion