diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2018-09-10 10:50:45 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2018-09-10 10:50:45 -0600 |
commit | 5ece6ef2f07c58672a9c965dbbbb62a42386fb2d (patch) | |
tree | 285e6382f9e900779bce60da02f1f0d97e467e26 /plugins/jenv | |
parent | 852e7fe005267f74f3c04a4ddbb310522eee8014 (diff) | |
parent | fe5fe81c8cfa66981c51d149a35fe545f2ef5016 (diff) | |
download | zsh-5ece6ef2f07c58672a9c965dbbbb62a42386fb2d.tar.gz zsh-5ece6ef2f07c58672a9c965dbbbb62a42386fb2d.tar.bz2 zsh-5ece6ef2f07c58672a9c965dbbbb62a42386fb2d.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/jenv')
-rw-r--r-- | plugins/jenv/README.md | 13 | ||||
-rw-r--r-- | plugins/jenv/jenv.plugin.zsh | 30 |
2 files changed, 43 insertions, 0 deletions
diff --git a/plugins/jenv/README.md b/plugins/jenv/README.md new file mode 100644 index 000000000..8899d21ae --- /dev/null +++ b/plugins/jenv/README.md @@ -0,0 +1,13 @@ +# jenv plugin + +[jenv](https://www.jenv.be/) is a Java version manager similiar to [rbenv](https://github.com/rbenv/rbenv) +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. + +To use, add `jenv` to your plugins array in your zshrc file: + +```zsh +plugins=(... jenv) +``` diff --git a/plugins/jenv/jenv.plugin.zsh b/plugins/jenv/jenv.plugin.zsh new file mode 100644 index 000000000..14c586be9 --- /dev/null +++ b/plugins/jenv/jenv.plugin.zsh @@ -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 + [[ -d "${jenvdir}/bin" ]] && 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 jenvdirs FOUND_JENV |