Add plenv plugin
Based mostly from pyenv plugin.
This commit is contained in:
parent
d310fac7f6
commit
de456f23b7
31
plugins/plenv/plenv.plugin.zsh
Normal file
31
plugins/plenv/plenv.plugin.zsh
Normal file
@ -0,0 +1,31 @@
|
||||
_homebrew-installed() {
|
||||
type brew &> /dev/null
|
||||
}
|
||||
|
||||
_plenv-from-homebrew-installed() {
|
||||
brew --prefix plenv &> /dev/null
|
||||
}
|
||||
|
||||
FOUND_PLENV=0
|
||||
plenvdirs=("$HOME/.plenv" "/usr/local/plenv" "/opt/plenv")
|
||||
if _homebrew-installed && _plenv-from-homebrew-installed ; then
|
||||
plenvdirs=($(brew --prefix plenv) "${plenvdirs[@]}")
|
||||
fi
|
||||
|
||||
for plenvdir in "${plenvdirs[@]}" ; do
|
||||
if [ -d $plenvdir/bin -a $FOUND_PLENV -eq 0 ] ; then
|
||||
FOUND_PLENV=1
|
||||
export PLENV_ROOT=$plenvdir
|
||||
export PATH=${plenvdir}/bin:$PATH
|
||||
eval "$(plenv init - zsh)"
|
||||
|
||||
function plenv_prompt_info() {
|
||||
echo "$(plenv version-name)"
|
||||
}
|
||||
fi
|
||||
done
|
||||
unset plenvdir
|
||||
|
||||
if [ $FOUND_PLENV -eq 0 ] ; then
|
||||
function plenv_prompt_info() { echo "system: $(perl -Mversion -e 'print version->parse($])->normal' 2>&1 )" }
|
||||
fi
|
Loading…
Reference in New Issue
Block a user