ohmyzsh/plugins/asdf/asdf.plugin.zsh
Muhammed Oguz 4bc1d27ef5 fix(asdf): allow plugin to initialize if asdf is installed in ~/.asdf
Previously, the plugin exited early if the `asdf` command was not already
in $PATH:

  (( ! $+commands[asdf] )) && return

This broke valid setups where `asdf` is installed manually in ~/.asdf
and not yet sourced globally (e.g., via .zshrc). Such installs are still
recommended in the official asdf documentation.

This change replaces the early exit with a check for the presence of
~/.asdf, so the plugin only runs if the user has a modern asdf setup,
while avoiding premature return before `$PATH` and completions are set up.

This preserves the new plugin behavior (removal of legacy <0.16 logic),
while restoring compatibility for the common manual install path.
2025-04-11 12:09:47 +03:00

16 lines
549 B
Bash

# Only continue if .asdf directory exists (manual install) or fallback logic can apply
if [[ ! -d "$HOME/.asdf" ]]; then
return
fi
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
path=("$ASDF_DATA_DIR/shims" $path)
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `asdf`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
typeset -g -A _comps
autoload -Uz _asdf
_comps[asdf]=_asdf
fi
asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|