# HG changeset patch # Parent ad9f207645abc9b06e61ee2f9426b1c0e0763b9c Correct usage of __VENV_NAME__ and add __VENV_PROMPT__ diff -r ad9f207645ab -r 509998437d5f Doc/library/venv.rst --- a/Doc/library/venv.rst Wed Oct 02 00:02:03 2013 +1000 +++ b/Doc/library/venv.rst Tue Oct 01 19:26:34 2013 +0100 @@ -187,6 +187,9 @@ * ``__VENV_NAME__`` is replaced with the environment name (final path segment of environment directory). + * ``__VENV_PROMPT__`` is replaced with the prompt (the environment + name surrounded by parentheses and with a following space) + * ``__VENV_BIN_NAME__`` is replaced with the name of the bin directory (either ``bin`` or ``Scripts``). diff -r ad9f207645ab -r 509998437d5f Lib/venv/__init__.py --- a/Lib/venv/__init__.py Wed Oct 02 00:02:03 2013 +1000 +++ b/Lib/venv/__init__.py Tue Oct 01 19:26:34 2013 +0100 @@ -261,7 +261,8 @@ being processed. """ text = text.replace('__VENV_DIR__', context.env_dir) - text = text.replace('__VENV_NAME__', context.prompt) + text = text.replace('__VENV_NAME__', context.env_name) + text = text.replace('__VENV_PROMPT__', context.prompt) text = text.replace('__VENV_BIN_NAME__', context.bin_name) text = text.replace('__VENV_PYTHON__', context.env_exe) return text diff -r ad9f207645ab -r 509998437d5f Lib/venv/scripts/nt/Activate.ps1 --- a/Lib/venv/scripts/nt/Activate.ps1 Wed Oct 02 00:02:03 2013 +1000 +++ b/Lib/venv/scripts/nt/Activate.ps1 Tue Oct 01 19:26:34 2013 +0100 @@ -34,7 +34,7 @@ function global:_OLD_VIRTUAL_PROMPT {""} copy-item function:prompt function:_OLD_VIRTUAL_PROMPT function global:prompt { - Write-Host -NoNewline -ForegroundColor Green '__VENV_NAME__' + Write-Host -NoNewline -ForegroundColor Green '__VENV_PROMPT__' _OLD_VIRTUAL_PROMPT } diff -r ad9f207645ab -r 509998437d5f Lib/venv/scripts/nt/activate.bat --- a/Lib/venv/scripts/nt/activate.bat Wed Oct 02 00:02:03 2013 +1000 +++ b/Lib/venv/scripts/nt/activate.bat Tue Oct 01 19:26:34 2013 +0100 @@ -14,7 +14,7 @@ ) set "_OLD_VIRTUAL_PROMPT=%PROMPT%" -set "PROMPT=__VENV_NAME__%PROMPT%" +set "PROMPT=__VENV_PROMPT__%PROMPT%" if defined PYTHONHOME ( set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" diff -r ad9f207645ab -r 509998437d5f Lib/venv/scripts/posix/activate --- a/Lib/venv/scripts/posix/activate Wed Oct 02 00:02:03 2013 +1000 +++ b/Lib/venv/scripts/posix/activate Tue Oct 01 19:26:34 2013 +0100 @@ -54,8 +54,8 @@ if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then _OLD_VIRTUAL_PS1="$PS1" - if [ "x__VENV_NAME__" != x ] ; then - PS1="__VENV_NAME__$PS1" + if [ "x__VENV_PROMPT__" != x ] ; then + PS1="__VENV_PROMPT__$PS1" else if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then # special case for Aspen magic directories diff -r ad9f207645ab -r 509998437d5f Lib/venv/scripts/posix/activate.fish --- a/Lib/venv/scripts/posix/activate.fish Wed Oct 02 00:02:03 2013 +1000 +++ b/Lib/venv/scripts/posix/activate.fish Tue Oct 01 19:26:34 2013 +0100 @@ -55,8 +55,8 @@ # with the original prompt function renamed, we can override with our own. function fish_prompt # Prompt override? - if test -n "__VENV_NAME__" - printf "%s%s%s" "__VENV_NAME__" (set_color normal) (_old_fish_prompt) + if test -n "__VENV_PROMPT__" + printf "%s%s%s" "__VENV_PROMPT__" (set_color normal) (_old_fish_prompt) return end # ...Otherwise, prepend env