Skip to content

Commit

Permalink
moved the batch prompt handling to activate.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
spetafree committed Feb 28, 2020
1 parent 2b24f15 commit 324315f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/virtualenv/activation/batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,3 @@ def instantiate_template(self, replacements, template, creator):
# ensure the text has all newlines as \r\n - required by batch
base = super(BatchActivator, self).instantiate_template(replacements, template, creator)
return base.replace(os.linesep, "\n").replace("\n", os.linesep)

def replacements(self, creator, dest_folder):
base_replacements = super(BatchActivator, self).replacements(creator, dest_folder)
if not base_replacements["__VIRTUAL_PROMPT__"]:
base_replacements["__VIRTUAL_PROMPT__"] = "(%s) " % creator.env_name
return base_replacements
8 changes: 7 additions & 1 deletion src/virtualenv/activation/batch/activate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ if defined _OLD_VIRTUAL_PROMPT (
)
)
if not defined VIRTUAL_ENV_DISABLE_PROMPT (
set "PROMPT=__VIRTUAL_PROMPT__%PROMPT%"
set ENV_PROMPT=__VIRTUAL_PROMPT__
if ["%ENV_PROMPT%"] == [""] (
for %%d in ("%VIRTUAL_ENV%") do set "VIRTUAL_ENV_NAME=%%~nxd"
set "ENV_PROMPT=(%VIRTUAL_ENV_NAME%) "
)
)
set "PROMPT=%ENV_PROMPT%%PROMPT%"
)

REM Don't use () to avoid problems with them in %PATH%
Expand Down

0 comments on commit 324315f

Please sign in to comment.