asdf.plugin.zsh 850 B

123456789101112131415161718192021222324252627
  1. # Find where asdf should be installed
  2. ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
  3. ASDF_COMPLETIONS="$ASDF_DIR/completions"
  4. # If not found, check for archlinux/AUR package (/opt/asdf-vm/)
  5. if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
  6. ASDF_DIR="/opt/asdf-vm"
  7. ASDF_COMPLETIONS="$ASDF_DIR"
  8. fi
  9. # If not found, check for Homebrew package
  10. if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
  11. brew_prefix="$(brew --prefix asdf)"
  12. ASDF_DIR="${brew_prefix}/libexec"
  13. ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
  14. unset brew_prefix
  15. fi
  16. # Load command
  17. if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
  18. . "$ASDF_DIR/asdf.sh"
  19. # Load completions
  20. if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
  21. . "$ASDF_COMPLETIONS/asdf.bash"
  22. fi
  23. fi