summaryrefslogtreecommitdiff
path: root/plugins/asdf/asdf.plugin.zsh
diff options
context:
space:
mode:
authorJohn Burwell <jburwell@users.noreply.github.com>2018-08-07 12:10:35 -0400
committerMarc Cornellà <marc.cornella@live.com>2018-08-07 18:10:35 +0200
commit05713785b0774f78e0aeb4cc4d793fdb529307db (patch)
tree09e4c0446fc561b8b10743d9d3fcb96479539a86 /plugins/asdf/asdf.plugin.zsh
parent91b771914bc7c43dd7c7a43b586c5de2c225ceb7 (diff)
downloadzsh-05713785b0774f78e0aeb4cc4d793fdb529307db.tar.gz
zsh-05713785b0774f78e0aeb4cc4d793fdb529307db.tar.bz2
zsh-05713785b0774f78e0aeb4cc4d793fdb529307db.zip
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.
Diffstat (limited to 'plugins/asdf/asdf.plugin.zsh')
-rw-r--r--plugins/asdf/asdf.plugin.zsh19
1 files 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