summaryrefslogtreecommitdiff
path: root/plugins/tailscale/tailscale.plugin.zsh
blob: 8b4e1e34d1f74b647d4c238295a2a99db36ab256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if (( ! $+commands[tailscale] && ! $+aliases[tailscale] )); then
  return
fi

# 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

  if (( $+commands[tailscale] )); then
    _comps[tailscale]=_tailscale
  elif (( $+aliases[tailscale] )); then
    _comps[${aliases[tailscale]:t}]=_tailscale
  fi
fi

# If using the alias, let's make sure that the aliased executable is also bound
# in case the alias points to "Tailscale" instead of "tailscale".
# See https://github.com/ohmyzsh/ohmyzsh/discussions/12928
if (( $+aliases[tailscale] )); then
  _comps[${aliases[tailscale]:t}]=_tailscale
fi

tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|