From 05713785b0774f78e0aeb4cc4d793fdb529307db Mon Sep 17 00:00:00 2001
From: John Burwell <jburwell@users.noreply.github.com>
Date: Tue, 7 Aug 2018 12:10:35 -0400
Subject: [PATCH] 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.
---
 plugins/asdf/asdf.plugin.zsh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
index d563cf5f8..75395c718 100644
--- a/plugins/asdf/asdf.plugin.zsh
+++ b/plugins/asdf/asdf.plugin.zsh
@@ -1,12 +1,17 @@
-# Find where asdf should be installed.
+# Find where asdf should be installed
 ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
 
-# Load asdf, if found.
-if [ -f $ASDF_DIR/asdf.sh ]; then
-    . $ASDF_DIR/asdf.sh
+# If not found, check for Homebrew package
+if [[ ! -d $ASDF_DIR ]] && (( $+commands[brew] )); then
+   ASDF_DIR="$(brew --prefix asdf)"
 fi
 
-# Load asdf completions, if found.
-if [ -f $ASDF_DIR/completions/asdf.bash ]; then
-    . $ASDF_DIR/completions/asdf.bash
+# Load command
+if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
+    . "$ASDF_DIR/asdf.sh"
+
+    # Load completions
+    if [[ -f "$ASDF_DIR/completions/asdf.bash" ]]; then
+        . "$ASDF_DIR/completions/asdf.bash"
+    fi
 fi
-- 
2.21.0