magic-wormhole icon indicating copy to clipboard operation
magic-wormhole copied to clipboard

shell completion via `wormhole completion bash/fish/zsh`

Open tigerinus opened this issue 1 year ago • 1 comments
trafficstars

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)

tigerinus avatar Apr 03 '24 02:04 tigerinus

Can you express this as a PR? (I don't use it this way so not sure how to test etc)

meejah avatar Apr 03 '24 07:04 meejah

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?

cgi-psaunders avatar Dec 09 '24 15:12 cgi-psaunders

This appears done from the Makefile: https://github.com/magic-wormhole/magic-wormhole/blob/master/Makefile#L19

feel free to reopen for more discussion

shapr avatar Apr 30 '25 15:04 shapr