Feature: Add active environment name to PROMPT env var (Windows Support)
See original GitHub issueOn unix/fish, when a shell is started using pipenv shell
, the $VIRTUAL_ENV
variable can be used to provide a visual indicator on the shell. For Example, if the users prompt is (~/folder) $
once the shell is activated using pipenv shell
the prompt becomes:
(~/folder) (pipenvfolder-1234) $
or similar. This currently works well with zsh/fish, etc and in general in the unix world is fairly easy to customize prompt.
On windows however, `%PROMPT% variable is used instead, and the variable is used by both cmd.exe and cmder console to add the virtual environment to the user’s prompt.
Upon activating an environment, the environment’s name is prepended to the $PROMPT
var.
As far as I know, this is not customizable on cmd.exe, and is not easily customizable with cmder neither.
cmd.exe behavior with virtualenv / virtualenv-wrapper
Active Environment is shown on prompt
cmder behavior with virtualenv / virtualenv-wrapper
Active Environment is shown on prompt
cmd and cmder with pipenv shell - No prompt indicator
Environment IS NOT shown anywhere on the prompt
Proposed solution
For the pipenv environment to be shown by default on the built-in cmd.exe and other windows-friendly consoles, pipenv could prepend the shell environment name to the PROMPT variable in the same way virtualenv does.
Virtualenv stores that old prompt in _OLD_VIRTUAL_PROMPT
so it can restore the original on deactivate, but pipenv would not need that since the process is destroyed.
Working example on cmd.exe
Working example on cmder
I would be happy to work on a PR if the proposal is accepted.
PS: Pipenv environment works perfectly out of the box on my fish shell
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
I agree with this (it’s an oversight Windows support is not added). Work on it! You might not need to mess with environment variables yourself, but can leverage existing scripts to do it. The activation is done in
core.activate_virtualenv
; try adding cases for cmd and Powershell first and see if that’s enough.This should be fixed with the above PR merge. (Please correct me if I’m wrong.)