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
8efcf277
"vscode:/vscode.git/clone" did not exist on "02d75684f3ddd2dcd181c9265545d5639d09bd5a"
Commit
8efcf277
authored
Apr 22, 2018
by
Terrance Kennedy
Committed by
Marc Cornellà
Apr 22, 2018
Browse files
pyenv plugin refactor (8x faster) (#6165)
* Refactor pyenv plugin to use PATH
parent
897a7da6
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/pyenv/pyenv.plugin.zsh
View file @
8efcf277
_homebrew-installed
()
{
type
brew &> /dev/null
}
# This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
_pyenv-from-homebrew-installed
()
{
brew
--prefix
pyenv &> /dev/null
}
FOUND_PYENV
=
0
pyenvdirs
=(
"
$HOME
/.pyenv"
"/usr/local/pyenv"
"/opt/pyenv"
)
for
pyenvdir
in
"
${
pyenvdirs
[@]
}
"
;
do
if
[
-d
$pyenvdir
/bin
-a
$FOUND_PYENV
-eq
0
]
;
then
FOUND_PYENV
=
1
export
PYENV_ROOT
=
$pyenvdir
export
PATH
=
${
pyenvdir
}
/bin:
$PATH
eval
"
$(
pyenv init - zsh
)
"
if
pyenv commands |
command grep
-q
virtualenv-init
;
then
eval
"
$(
pyenv virtualenv-init - zsh
)
"
fi
function
pyenv_prompt_info
()
{
echo
"
$(
pyenv version-name
)
"
}
fi
done
unset
pyenvdir
if
[
$FOUND_PYENV
-eq
0
]
;
then
pyenvdir
=
$(
brew
--prefix
pyenv 2> /dev/null
)
if
[
$?
-eq
0
-a
-d
$pyenvdir
/bin
]
;
then
FOUND_PYENV
=
1
export
PYENV_ROOT
=
$pyenvdir
export
PATH
=
${
pyenvdir
}
/bin:
$PATH
eval
"
$(
pyenv init - zsh
)
"
if
pyenv commands |
command grep
-q
virtualenv-init
;
then
eval
"
$(
pyenv virtualenv-init - zsh
)
"
fi
function
pyenv_prompt_info
()
{
echo
"
$(
pyenv version-name
)
"
}
if
((
$+
commands[pyenv]
))
;
then
eval
"
$(
pyenv init - zsh
)
"
if
((
$+
commands[pyenv-virtualenv-init]
))
;
then
eval
"
$(
pyenv virtualenv-init - zsh
)
"
fi
fi
if
[
$FOUND_PYENV
-eq
0
]
;
then
function
pyenv_prompt_info
()
{
echo
"system:
$(
python
-V
2>&1 |
cut
-f
2
-d
' '
)
"
}
function
pyenv_prompt_info
()
{
echo
"
$(
pyenv version-name
)
"
}
else
# fallback to system python
function
pyenv_prompt_info
()
{
echo
"system:
$(
python
-V
2>&1 |
cut
-f
2
-d
' '
)
"
}
fi
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