Optimize and use idiomatic zsh

This commit is contained in:
Marc Cornellà 2024-11-19 20:30:47 +01:00
commit af41403a5b
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,4 +1,4 @@
if (( ! ($+commands[tailscale] || $+aliases[tailscale]) )); then
if (( ! $+commands[tailscale] && ! $+aliases[tailscale] )); then
return
fi
@ -7,10 +7,11 @@ fi
if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
typeset -g -A _comps
autoload -Uz _tailscale
_comps[tailscale]=_tailscale
if (( $+aliases[tailscale] )); then
# `basename "$(alias tailscale | sed "s/.*=\(.*\)/\1/")"` should output executable name
compdef "$(basename "$(alias tailscale | sed "s/.*=\(.*\)/\1/")")"="tailscale"
if (( $+commands[tailscale] )); then
_comps[tailscale]=_tailscale
elif (( $+aliases[tailscale] )); then
_comps[${aliases[tailscale]:t}]=_tailscale
fi
fi