Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
3a822bb5
Commit
3a822bb5
authored
Aug 19, 2018
by
Marc Cornellà
Browse files
jenv: refactor and optimize logic
parent
e8b99589
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/jenv/jenv.plugin.zsh
View file @
3a822bb5
_homebrew-installed
()
{
type
brew &> /dev/null
}
_jenv-from-homebrew-installed
()
{
brew
--prefix
jenv &> /dev/null
}
jenvdirs
=(
"
$HOME
/.jenv"
"/usr/local/jenv"
"/opt/jenv"
)
if
_homebrew-installed
&&
_jenv-from-homebrew-installed
;
then
jenvdirs+
=(
$(
brew
--prefix
jenv
)
"
${
jenvdirs
[@]
}
"
)
fi
FOUND_JENV
=
0
for
jenvdir
in
"
${
jenvdirs
[@]
}
"
;
do
if
[
-d
$
jenvdir
/bin
-a
$FOUND_JENV
-eq
0
]
;
then
for
jenvdir
in
$
jenvdirs
;
do
if
[
[
-d
"
${
jenvdir
}
/bin
"
]]
;
then
FOUND_JENV
=
1
export
PATH
=
"
${
jenvdir
}
/bin:
$PATH
"
eval
"
$(
jenv init - zsh
)
"
break
fi
done
function
jenv_prompt_info
()
{
echo
"
$(
jenv version-name
)
"
}
if
[[
$FOUND_JENV
-eq
0
]]
;
then
if
((
$+
commands[brew]
))
&&
jenvdir
=
"
$(
brew
--prefix
jenv
)
"
;
then
FOUND_JENV
=
1
fi
if
[
-d
$jenvdir
/versions
-a
$FOUND_JENV
-eq
0
]
;
then
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
done
unset
jenvdir
if
[
$FOUND_JENV
-eq
0
]
;
then
else
function
jenv_prompt_info
()
{
echo
"system:
$(
java
-version
2>&1 |
cut
-f
2
-d
' '
)
"
}
fi
unset
jenvdir FOUND_JENV
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment