mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-16 19:00:07 +00:00
Merge branch 'jburwell/jenv-plugin'
Closes #3406 Closes #4972 Closes #4523 Closes #5964
This commit is contained in:
commit
cb7a3e38aa
3 changed files with 34 additions and 1 deletions
|
@ -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
3
plugins/jenv/README.md
Normal 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.
|
30
plugins/jenv/jenv.plugin.zsh
Normal file
30
plugins/jenv/jenv.plugin.zsh
Normal 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
|
Loading…
Reference in a new issue