tailscale.plugin.zsh 863 B

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