mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-13 14:03:53 -05:00
Merge pull request #78 from blueyed/shell-no-note-if-init
activate: do not display note if initialized already
This commit is contained in:
@@ -68,27 +68,11 @@ if ! pyenv-virtualenv-prefix "${versions}" 1>/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
shell="${PYENV_SHELL:-${SHELL##*/}}"
|
||||||
case "$shell" in
|
|
||||||
bash )
|
|
||||||
profile="$HOME/.bash_profile"
|
|
||||||
;;
|
|
||||||
zsh )
|
|
||||||
profile="$HOME/.zshrc"
|
|
||||||
;;
|
|
||||||
ksh )
|
|
||||||
profile="$HOME/.profile"
|
|
||||||
;;
|
|
||||||
fish )
|
|
||||||
profile="$HOME/.config/fish/config.fish"
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
profile="$HOME/.profile"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Display setup instruction if 'pyenv virtualenv-init -' is not found in "$profile"
|
# Display setup instruction, if pyenv-virtualenv has not been initialized.
|
||||||
if [ -f "$profile" ] && grep -q 'pyenv init -' "$profile" && ! grep -q 'pyenv virtualenv-init -' "$profile"; then
|
# if 'pyenv virtualenv-init -' is not found in "$profile"
|
||||||
|
if [ -z "$PYENV_VIRTUALENV_INIT" ]; then
|
||||||
pyenv-virtualenv-init >&2 || true
|
pyenv-virtualenv-init >&2 || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
shell="$1"
|
shell="${1:-$PYENV_SHELL}"
|
||||||
if [ -z "$shell" ]; then
|
if [ -z "$shell" ]; then
|
||||||
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
|
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
|
||||||
shell="${shell##-}"
|
shell="${shell##-}"
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.bash_profile:
|
||||||
|
|
||||||
|
eval "\$(pyenv virtualenv-init -)"
|
||||||
|
|
||||||
pyenv shell "venv";
|
pyenv shell "venv";
|
||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
unset PYENV_DEACTIVATE;
|
unset PYENV_DEACTIVATE;
|
||||||
@@ -109,6 +114,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.config/fish/config.fish:
|
||||||
|
|
||||||
|
status --is-interactive; and . (pyenv virtualenv-init -|psub)
|
||||||
|
|
||||||
pyenv shell "venv";
|
pyenv shell "venv";
|
||||||
setenv PYENV_ACTIVATE_SHELL 1;
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
set -e PYENV_DEACTIVATE;
|
set -e PYENV_DEACTIVATE;
|
||||||
@@ -151,6 +161,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.bash_profile:
|
||||||
|
|
||||||
|
eval "\$(pyenv virtualenv-init -)"
|
||||||
|
|
||||||
pyenv shell "venv27";
|
pyenv shell "venv27";
|
||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
unset PYENV_DEACTIVATE;
|
unset PYENV_DEACTIVATE;
|
||||||
@@ -193,6 +208,11 @@ EOS
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
# Load pyenv-virtualenv automatically by adding
|
||||||
|
# the following to ~/.config/fish/config.fish:
|
||||||
|
|
||||||
|
status --is-interactive; and . (pyenv virtualenv-init -|psub)
|
||||||
|
|
||||||
pyenv shell "venv27";
|
pyenv shell "venv27";
|
||||||
setenv PYENV_ACTIVATE_SHELL 1;
|
setenv PYENV_ACTIVATE_SHELL 1;
|
||||||
set -e PYENV_DEACTIVATE;
|
set -e PYENV_DEACTIVATE;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
@test "detect parent shell" {
|
@test "detect parent shell" {
|
||||||
|
unset PYENV_SHELL
|
||||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||||
SHELL=/bin/false run pyenv-virtualenv-init -
|
SHELL=/bin/false run pyenv-virtualenv-init -
|
||||||
assert_success
|
assert_success
|
||||||
|
|||||||
Reference in New Issue
Block a user