Commit dff9e253 authored by Vinay Sajip's avatar Vinay Sajip

Closes #19139: Changed usage of __VENV_NAME__ and added __VENV_PROMPT__.

parent 7c411a40
...@@ -187,6 +187,9 @@ creation according to their needs, the :class:`EnvBuilder` class. ...@@ -187,6 +187,9 @@ creation according to their needs, the :class:`EnvBuilder` class.
* ``__VENV_NAME__`` is replaced with the environment name (final path * ``__VENV_NAME__`` is replaced with the environment name (final path
segment of environment directory). 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 * ``__VENV_BIN_NAME__`` is replaced with the name of the bin directory
(either ``bin`` or ``Scripts``). (either ``bin`` or ``Scripts``).
......
...@@ -261,7 +261,8 @@ class EnvBuilder: ...@@ -261,7 +261,8 @@ class EnvBuilder:
being processed. being processed.
""" """
text = text.replace('__VENV_DIR__', context.env_dir) 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_BIN_NAME__', context.bin_name)
text = text.replace('__VENV_PYTHON__', context.env_exe) text = text.replace('__VENV_PYTHON__', context.env_exe)
return text return text
......
...@@ -34,7 +34,7 @@ $env:VIRTUAL_ENV="__VENV_DIR__" ...@@ -34,7 +34,7 @@ $env:VIRTUAL_ENV="__VENV_DIR__"
function global:_OLD_VIRTUAL_PROMPT {""} function global:_OLD_VIRTUAL_PROMPT {""}
copy-item function:prompt function:_OLD_VIRTUAL_PROMPT copy-item function:prompt function:_OLD_VIRTUAL_PROMPT
function global:prompt { function global:prompt {
Write-Host -NoNewline -ForegroundColor Green '__VENV_NAME__' Write-Host -NoNewline -ForegroundColor Green '__VENV_PROMPT__'
_OLD_VIRTUAL_PROMPT _OLD_VIRTUAL_PROMPT
} }
......
...@@ -14,7 +14,7 @@ if defined _OLD_VIRTUAL_PYTHONHOME ( ...@@ -14,7 +14,7 @@ if defined _OLD_VIRTUAL_PYTHONHOME (
) )
set "_OLD_VIRTUAL_PROMPT=%PROMPT%" set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
set "PROMPT=__VENV_NAME__%PROMPT%" set "PROMPT=__VENV_PROMPT__%PROMPT%"
if defined PYTHONHOME ( if defined PYTHONHOME (
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
......
...@@ -54,8 +54,8 @@ fi ...@@ -54,8 +54,8 @@ fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1" _OLD_VIRTUAL_PS1="$PS1"
if [ "x__VENV_NAME__" != x ] ; then if [ "x__VENV_PROMPT__" != x ] ; then
PS1="__VENV_NAME__$PS1" PS1="__VENV_PROMPT__$PS1"
else else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories # special case for Aspen magic directories
......
...@@ -55,8 +55,8 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" ...@@ -55,8 +55,8 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# with the original prompt function renamed, we can override with our own. # with the original prompt function renamed, we can override with our own.
function fish_prompt function fish_prompt
# Prompt override? # Prompt override?
if test -n "__VENV_NAME__" if test -n "__VENV_PROMPT__"
printf "%s%s%s" "__VENV_NAME__" (set_color normal) (_old_fish_prompt) printf "%s%s%s" "__VENV_PROMPT__" (set_color normal) (_old_fish_prompt)
return return
end end
# ...Otherwise, prepend env # ...Otherwise, prepend env
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment