jenv.plugin.zsh 787 Bytes
Newer Older
1
jenvdirs=("$HOME/.jenv" "/usr/local/bin/jenv" "/usr/local/jenv" "/opt/jenv")
John Burwell's avatar
John Burwell committed
2
3

FOUND_JENV=0
4
5
for jenvdir in $jenvdirs; do
    if [[ -d "${jenvdir}/bin" ]]; then
John Burwell's avatar
John Burwell committed
6
        FOUND_JENV=1
7
8
9
        break
    fi
done
John Burwell's avatar
John Burwell committed
10

11
12
if [[ $FOUND_JENV -eq 0 ]]; then
    if (( $+commands[brew] )) && jenvdir="$(brew --prefix jenv)"; then
13
        [[ -d "${jenvdir}/bin" ]] && FOUND_JENV=1
John Burwell's avatar
John Burwell committed
14
    fi
15
16
17
fi

if [[ $FOUND_JENV -eq 1 ]]; then
18
    (( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH"
19
20
21
22
23
    eval "$(jenv init - zsh)"

    function jenv_prompt_info() { jenv version-name 2>/dev/null }

    if [[ -d "${jenvdir}/versions" ]]; then
John Burwell's avatar
John Burwell committed
24
25
        export JENV_ROOT=$jenvdir
    fi
26
else
John Burwell's avatar
John Burwell committed
27
28
    function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" }
fi
29

Marc Cornellà's avatar
Marc Cornellà committed
30
unset jenvdir jenvdirs FOUND_JENV