Skip to content

Commit 008c2b3

Browse files
author
Noah Gorny
authored
Merge pull request Bash-it#1885 from cornfeedhobo/pyenv-path
clean up pyenv plugin
2 parents 3eed0f0 + ec075a4 commit 008c2b3

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

plugins/available/pyenv.plugin.bash

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,33 @@
22
cite about-plugin
33
about-plugin 'load pyenv, if you are using it'
44

5-
export PYENV_ROOT="$HOME/.pyenv"
6-
pathmunge "$PYENV_ROOT/bin"
5+
# https://github.com/pyenv/pyenv
76

8-
if _command_exists pyenv; then
9-
eval "$(pyenv init - bash)"
7+
# Load after basher
8+
# BASH_IT_LOAD_PRIORITY: 260
9+
10+
# Don't modify the environment if we can't find the tool:
11+
# - Check if in $PATH already
12+
# - Check if installed manually to $PYENV_ROOT
13+
# - Check if installed manually to $HOME
14+
_command_exists pyenv \
15+
|| [[ -n "$PYENV_ROOT" && -x "$PYENV_ROOT/bin/pyenv" ]] \
16+
|| [[ -x "$HOME/.pyenv/bin/pyenv" ]] \
17+
|| return 0
18+
19+
# Set PYENV_ROOT, if not already set
20+
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
21+
22+
# Add PYENV_ROOT/bin to PATH, if that's where it's installed
23+
if ! _command_exists pyenv && [[ -x "$PYENV_ROOT/bin/pyenv" ]]; then
24+
pathmunge "$PYENV_ROOT/bin"
1025
fi
1126

12-
#Load pyenv virtualenv if the virtualenv plugin is installed.
27+
# Initialize pyenv
28+
pathmunge "$PYENV_ROOT/shims"
29+
eval "$(pyenv init - bash)"
30+
31+
# Load pyenv virtualenv if the virtualenv plugin is installed.
1332
if pyenv virtualenv-init - &> /dev/null; then
1433
eval "$(pyenv virtualenv-init - bash)"
1534
fi

0 commit comments

Comments
 (0)