asdf: fix homebrew installation path (#7582)
* The check for the asdf installation directory is more precise:
The existence of the directory `$HOME/.asdf` does not mean that it is the installation
directory of `asdf`. It will also be created after installing at least one asdf plugin.
* Completions, while installed with homebrew, are now expected on an alternative location.
Diff
1diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
2index 75395c718a0c40627bbe523852de1d9a80fe44b5..38b2255383ef00ad7dd8ea0396b1c669fc229451 100644
3--- a/plugins/asdf/asdf.plugin.zsh
4+++ b/plugins/asdf/asdf.plugin.zsh
5@@ -1,9 +1,11 @@
6 # Find where asdf should be installed
7 ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
8+ASDF_COMPLETIONS="$ASDF_DIR/completions"
910 # If not found, check for Homebrew package
11-if [[ ! -d $ASDF_DIR ]] && (( $+commands[brew] )); then
12+if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then
13 ASDF_DIR="$(brew --prefix asdf)"
14+ ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
15 fi
1617 # Load command
18@@ -11,7 +13,7 @@ if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
19 . "$ASDF_DIR/asdf.sh"
2021 # Load completions
22- if [[ -f "$ASDF_DIR/completions/asdf.bash" ]]; then
23- . "$ASDF_DIR/completions/asdf.bash"
24+ if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
25+ . "$ASDF_COMPLETIONS/asdf.bash"
26 fi
27 fi