tailscale.plugin.zsh
863 bytes
1if (( ! $+commands[tailscale] && ! $+aliases[tailscale] )); then
2 return
3fi
4
5# If the completion file doesn't exist yet, we need to autoload it and
6# bind it to `tailscale`. Otherwise, compinit will have already done that.
7if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
8 typeset -g -A _comps
9 autoload -Uz _tailscale
10
11 if (( $+commands[tailscale] )); then
12 _comps[tailscale]=_tailscale
13 elif (( $+aliases[tailscale] )); then
14 _comps[${aliases[tailscale]:t}]=_tailscale
15 fi
16fi
17
18# If using the alias, let's make sure that the aliased executable is also bound
19# in case the alias points to "Tailscale" instead of "tailscale".
20# See https://github.com/ohmyzsh/ohmyzsh/discussions/12928
21if (( $+aliases[tailscale] )); then
22 _comps[${aliases[tailscale]:t}]=_tailscale
23fi
24
25tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|