0
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-09-19 04:01:21 +02:00

Merge branch 'jburwell/jenv-plugin'

Closes #3406
Closes #4972
Closes #4523
Closes #5964
This commit is contained in:
Marc Cornellà 2018-08-19 19:36:52 +02:00
commit cb7a3e38aa
3 changed files with 34 additions and 1 deletions

View file

@ -12,7 +12,7 @@
# Real implementations will be used when the respective plugins are loaded
function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
virtualenv_prompt_info {
virtualenv_prompt_info jenv_prompt_info {
return 1
}

3
plugins/jenv/README.md Normal file
View file

@ -0,0 +1,3 @@
# jenv oh-my-zsh plugin
[jenv](http://www.jenv.be/) is a Java version manager similiar to [rbenv](http://rbenv.org/) and [pyenv]|(https://github.com/yyuu/pyenv). This plugin initializes jenv and adds provides the jenv_prompt_info function to add Java version information to prompts.

View file

@ -0,0 +1,30 @@
jenvdirs=("$HOME/.jenv" "/usr/local/jenv" "/opt/jenv")
FOUND_JENV=0
for jenvdir in $jenvdirs; do
if [[ -d "${jenvdir}/bin" ]]; then
FOUND_JENV=1
break
fi
done
if [[ $FOUND_JENV -eq 0 ]]; then
if (( $+commands[brew] )) && jenvdir="$(brew --prefix jenv)"; then
FOUND_JENV=1
fi
fi
if [[ $FOUND_JENV -eq 1 ]]; then
export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)"
function jenv_prompt_info() { jenv version-name 2>/dev/null }
if [[ -d "${jenvdir}/versions" ]]; then
export JENV_ROOT=$jenvdir
fi
else
function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" }
fi
unset jenvdir FOUND_JENV