From 9f3afd0cfb7e24e4693761761a03fc6a0e122df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovier=20A=2E=20Jim=C3=A9nez?= Date: Mon, 19 Feb 2024 21:18:56 -0800 Subject: [PATCH 1/3] allow users to configure prompt add-on --- bin/pyenv-sh-activate | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index d6b0d35..70072b9 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -262,9 +262,14 @@ EOS fi ;; * ) + if [ -z "${PYENV_VIRTUALENV_PROMPT}" ]; then + PYENV_VIRTUALENV_PROMPT="(${venv})" + else + PYENV_VIRTUALENV_PROMPT="${PYENV_VIRTUALENV_PROMPT/\{venv\}/${venv}}" + fi cat < Date: Mon, 19 Feb 2024 21:19:08 -0800 Subject: [PATCH 2/3] update tests --- test/activate.bats | 25 +++++++++++++++++++++++++ test/conda-activate.bats | 29 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/test/activate.bats b/test/activate.bats index 9c1fc67..4a3455a 100644 --- a/test/activate.bats +++ b/test/activate.bats @@ -44,6 +44,31 @@ EOS unstub pyenv-sh-deactivate } +@test "activate virtualenv from current version with custom prompt" { + export PYENV_VIRTUALENV_INIT=1 + + stub pyenv-version-name "echo venv" + stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\"" + stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\"" + stub pyenv-sh-deactivate "--force --quiet : echo deactivated" + + PYENV_SHELL="bash" PYENV_VERSION="venv" PYENV_VIRTUALENV_PROMPT='venv:{venv}' run pyenv-sh-activate + + assert_success + assert_output < Date: Mon, 19 Feb 2024 21:30:57 -0800 Subject: [PATCH 3/3] update README with example --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6682980..dbbaf06 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ You can set certain environment variables to control pyenv-virtualenv. * `PIP_VERSION`, if set and `venv` is preferred over `virtualenv`, install the specified version of pip. * `PYENV_VIRTUALENV_VERBOSE_ACTIVATE`, if set, shows some verbose outputs on activation and deactivation +* `PYENV_VIRTUALENV_PROMPT`, if set, allows users to customize how `pyenv-virtualenv` modifies their shell prompt. The default prompt ("(venv)") is overwritten with any user-specified text. Specify the location of the virtual environment name with the string `{venv}`. ## Version History