mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-06-05 05:03:16 +02:00
Adds Homebrew and completion support to asdf plugin
* Modifies the search logic for asdf to include Homebrew when it is installed. The implementation is adapted from the pyenv plugin. Per feedback from @mcornella, asdf is either going to be in the Homebrew directory or $HOME/.asdf. Since no distributions appear to package asdf, the other locations are unncecessary. This new assumption allowed the search logic to be simplified as well. * Includes command completions for both regular and Homebrew installs. This enhancement was inspired by PR $6045.
This commit is contained in:
parent
45a9f28464
commit
387ab91ec3
1 changed files with 29 additions and 8 deletions
|
|
@ -1,12 +1,33 @@
|
||||||
# Find where asdf should be installed.
|
_homebrew-installed() {
|
||||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
type brew &> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# Load asdf, if found.
|
FOUND_ASDF=0
|
||||||
if [ -f $ASDF_DIR/asdf.sh ]; then
|
DEFAULT_ASDF_DIR="$HOME/.asdf"
|
||||||
|
|
||||||
|
if [ -d $DEFAULT_ASDF_DIR/bin ] ; then
|
||||||
|
FOUND_ASDF=1
|
||||||
|
ASDF_DIR="$DEFAULT_ASDF_DIR"
|
||||||
|
ASDF_COMPLETIONS_DIR="$DEFAULT_ASDF_DIR/completions"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $FOUND_ASDF -eq 0 ] && _homebrew-installed ; then
|
||||||
|
ASDF_DIR="$(brew --prefix)/opt/asdf"
|
||||||
|
if [ $? -eq 0 -a -d $ASDF_DIR/bin ] ; then
|
||||||
|
FOUND_ASDF=1
|
||||||
|
ASDF_COMPLETIONS_DIR="$ASDF_DIR/etc/bash_completion.d/asdf.bash"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $FOUND_ASDF -gt 0 ] ; then
|
||||||
|
export PATH=${ASDF_DIR}/bin:$PATH
|
||||||
. $ASDF_DIR/asdf.sh
|
. $ASDF_DIR/asdf.sh
|
||||||
|
if [ -f $ASDF_COMPLETIONS_DIR/completions/asdf.bash ]; then
|
||||||
|
. $ASDF_COMPLETIONS_DIR/completions/asdf.bash
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load asdf completions, if found.
|
unset FOUND_ASDF
|
||||||
if [ -f $ASDF_DIR/completions/asdf.bash ]; then
|
unset ASDF_DIR
|
||||||
. $ASDF_DIR/completions/asdf.bash
|
unset ASDF_COMPLETIONS_DIR
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue