05713785b0774f78e0aeb4cc4d793fdb529307db

Author
John Burwell <jburwell@users.noreply.github.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

asdf: add Homebrew and completion support (#6749)

* Modifies the search logic for asdf to include Homebrew when it is
installed. The implementation is adapted from the pyenv plugin.

Diff

 1diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
 2index d563cf5f8e84746d7dff03da165680c06c840d5b..75395c718a0c40627bbe523852de1d9a80fe44b5 100644
 3--- a/plugins/asdf/asdf.plugin.zsh
 4+++ b/plugins/asdf/asdf.plugin.zsh
 5@@ -1,12 +1,17 @@
 6-# Find where asdf should be installed.
 7+# Find where asdf should be installed
 8 ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
 9 
10-# Load asdf, if found.
11-if [ -f $ASDF_DIR/asdf.sh ]; then
12-    . $ASDF_DIR/asdf.sh
13+# If not found, check for Homebrew package
14+if [[ ! -d $ASDF_DIR ]] && (( $+commands[brew] )); then
15+   ASDF_DIR="$(brew --prefix asdf)"
16 fi
17 
18-# Load asdf completions, if found.
19-if [ -f $ASDF_DIR/completions/asdf.bash ]; then
20-    . $ASDF_DIR/completions/asdf.bash
21+# Load command
22+if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
23+    . "$ASDF_DIR/asdf.sh"
24+
25+    # Load completions
26+    if [[ -f "$ASDF_DIR/completions/asdf.bash" ]]; then
27+        . "$ASDF_DIR/completions/asdf.bash"
28+    fi
29 fi