]> granicus.if.org Git - python/commitdiff
Closes #19139: Changed usage of __VENV_NAME__ and added __VENV_PROMPT__.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 2 Oct 2013 10:36:16 +0000 (11:36 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 2 Oct 2013 10:36:16 +0000 (11:36 +0100)
Doc/library/venv.rst
Lib/venv/__init__.py
Lib/venv/scripts/nt/Activate.ps1
Lib/venv/scripts/nt/activate.bat
Lib/venv/scripts/posix/activate
Lib/venv/scripts/posix/activate.fish

index 2fb5cdae048796c2c9a0f0c07a3d196d4e4d6a04..eda0cb6bf307f583c3662d7fc4a364a4b9e778f3 100644 (file)
@@ -187,6 +187,9 @@ creation according to their needs, the :class:`EnvBuilder` class.
         * ``__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``).
 
index 1688bc4ab74082dc9c5d94f24ff413d23423c5f1..f184328e14419be003678366da71c6f307617f64 100644 (file)
@@ -261,7 +261,8 @@ class EnvBuilder:
                         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
index df789633ce4a4bccaa644d33f21f73c1964e2c88..b15decb9c584a64809105ec6f7c0148ec10ba9b0 100644 (file)
@@ -34,7 +34,7 @@ $env:VIRTUAL_ENV="__VENV_DIR__"
 function global:_OLD_VIRTUAL_PROMPT {""}\r
 copy-item function:prompt function:_OLD_VIRTUAL_PROMPT\r
 function global:prompt {\r
-    Write-Host -NoNewline -ForegroundColor Green '__VENV_NAME__'\r
+    Write-Host -NoNewline -ForegroundColor Green '__VENV_PROMPT__'\r
     _OLD_VIRTUAL_PROMPT\r
 }\r
 \r
index 3cebe263818b3f20f6d15cc763402d68cd427109..9eab147f314d3b2db9f34f4034eba077b0664103 100644 (file)
@@ -14,7 +14,7 @@ if defined _OLD_VIRTUAL_PYTHONHOME (
 )\r
 \r
 set "_OLD_VIRTUAL_PROMPT=%PROMPT%"\r
-set "PROMPT=__VENV_NAME__%PROMPT%"\r
+set "PROMPT=__VENV_PROMPT__%PROMPT%"\r
 \r
 if defined PYTHONHOME (\r
     set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"\r
index c241450c0b0ba4f0c1a045efe50d8df6d93dd3b7..7bbffd9ba69d47a7552a7c7c7918bf72ae3ada54 100644 (file)
@@ -54,8 +54,8 @@ fi
 
 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
index 5ac1638d29e7b23d3ca7a608ff5c3aefd62ffd18..45391aa01c9d50f30afef81daa9ea9048ae461c8 100644 (file)
@@ -55,8 +55,8 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
     # 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