-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add active environment name to PROMPT env var (Windows Support) #2116
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 |
I actually wrote some Lua to do this in Cmder :p I don’t have my Windows machine around now, but can probably add a page to wiki about this. |
FYI we have discussed this in the past and rejected it because cross platform support is hard, but if you can come up with something we’d review |
Can you guys point me to the discussion so I don't make the same mistake and propose the same thing :) Do we not use the same activate script from virtualenvs bat to activate on windows? |
The catch is that you cannot assume CMD (there’s Powershell, and as you know Fish etc. also work), and contrary to POSIX, shell detection on Windows is much more difficult. |
This should be fixed with the above PR merge. (Please correct me if I’m wrong.) |
On 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
The text was updated successfully, but these errors were encountered: