diff options
| author | Carlo Sala <carlosalag@protonmail.com> | 2024-08-29 12:19:19 +0200 |
|---|---|---|
| committer | Carlo Sala <carlosalag@protonmail.com> | 2024-08-29 12:19:19 +0200 |
| commit | ea8068aa3eeecc785249f2e83289e8a9294b9d6b (patch) | |
| tree | fdddd02ae201853de80bb1eb075431d982a3da49 /plugins/tailscale | |
| parent | e2ba73af6342fed58c1b26391f105a447110d520 (diff) | |
| download | zsh-ea8068aa3eeecc785249f2e83289e8a9294b9d6b.tar.gz zsh-ea8068aa3eeecc785249f2e83289e8a9294b9d6b.tar.bz2 zsh-ea8068aa3eeecc785249f2e83289e8a9294b9d6b.zip | |
fix(tailscale): make completion loading async
Diffstat (limited to 'plugins/tailscale')
| -rw-r--r-- | plugins/tailscale/tailscale.plugin.zsh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/tailscale/tailscale.plugin.zsh b/plugins/tailscale/tailscale.plugin.zsh index ae664a665..7f0b1414a 100644 --- a/plugins/tailscale/tailscale.plugin.zsh +++ b/plugins/tailscale/tailscale.plugin.zsh @@ -1,4 +1,13 @@ +if (( ! $+commands[tailscale] )); then + return +fi -if [ $commands[tailscale] ]; then - source <(tailscale completion zsh) +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `tailscale`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then + typeset -g -A _comps + autoload -Uz _tailscale + _comps[tailscale]=_tailscale fi + +tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &| |
