-
-
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
pipenv powershell shell should label prompt when inside pipenv shell (similar to venv) #3505
Comments
sounds like a good idea, but doesn't it already prepend something? or is the suggestion to specifically add that it is a pipenv environment? |
It does not appear to do so. Not in the powershell window title nor in the powershell prompt. Nor in the MinGW bash prompt.
Yes. With many powershell windows open, which powershell belongs to which environment (or no environment) becomes confusing. I created a reasonable wrapper script to set the powershell window title. It appends a string like " |
I like the idea of |
As a user, I really care about the actual path in use. It gives me a better sense of which pipenv is in use and where it lives and operates from. My two ¢ |
The actual path is indeed useful, but what @techalchemy referred to was the hash of the path (which Pipenv uses to identify projects). Anyway, the prompt information is already there, it only needs to be implemented for Powershell. The only reason this is not already done is because it’s more difficult to do in Powershell than other common shells :) |
Ah, pardon me.
In my case, I still do care. I'm not certain if the hash fragment is actually meaningful assurance in those two scenarios but it feels like it is. I know the hash fragment is simply a hash of the path. However, I'm not entirely certain some other subtle mechanism changes between creating -> destroying -> creating a pipenv environment at the same path. Also, if I decide move/rename the project directory or a parent directory ... well, I'm not sure what occurs to already-established pipenv environments in that case. Either way, the hash fragment seems like a good thing to make readily visible for users like me. |
Cannot agree more. I was linked to this issue page after I asked this on SO. I moved from Pycharm to VSCode and I found that the prepended (pipenv) is missing. Turned out Pycharm guys cleverly made their own configuration to better show that the user is in pipenv. It is a default feature in Pycharm if you make virtualenv with pipenv in the option. In VSCode, pipenv is inidicated in the dropbox at the right corner of the terminal that shows which shell you're using. One way to tell whether you're on pipenv virtualenv is to type |
I've hacked this together and put it in
|
Here is what I use to get a specific prompt for each environment (faster than above as it does not run a command every time the prompt is evaluated):
See https://ss64.com/ps/syntax-prompt.html on how to update your configuration to include this. |
Here is some refactoring of code above
|
PS: It seems the method below have no practical use because this script doesn't run pipenv shell command, thus subshell not activated. The method above recommended. I found out there is already exists properly made PowerShell Script out of the box.
|
thanks for this. is there any update on whether we'll be able to get this functionality when using |
This still appears to be an issue with not showing the virtualenv or anything prepended when the shell is active on the windows side. same for git shell, cmd and power shell. |
For me this worked #4264 (comment) Powershell is supported and you can enable it using the environment variable
before running |
tl;dr
pipenv shell
should label the powershell prompt when inside a shell. This is whatvenv
currently does. Something like(pipenv: project1-LQTIN6Io) PS C:\Users\user1\Projects\project1>
venv module
When using the
venv
module and then entering the virtual environment shell, the shell prompt becomes labeled. Here's an example in powershell:I find the prepended label "
(.venv)
" tremendously helpful. That prepended label is also colored green which is different than the remainder of the powershell prompt "PS C:\Users\user1\Projects>
" in light-gray. It's easy to visually distinguish the green string "(.venv)
" was prepended to the default powershell prompt. I often have several powershell windows open. That prepended label helps me remember which powershell window is currently in a python virtual environment.this pipenv enhancement follows venv module
This Enhancement is to recommend pipenv implement the same feature. I imagine this would look like
Notice the prepended prompt string "
(pipenv: project1-LQTIN6Io)
". Ideally, it would also be colorized different than the remaining prompt string.This Issue is similar to pipenv Issue #40 (which addressed bash shell).
btw, after reading Pipenv: A Guide to the New Python Packaging Tool (realpython.com), I really want more pipenv!
Additional context
$ pipenv --support
Pipenv version:
'2018.11.26'
Pipenv location:
'c:\\python\\python37\\lib\\site-packages\\pipenv'
Python location:
'c:\\python\\python37\\python.exe'
Python installations found:
3.7.1
:C:\Python\Python37\python.exe
3.6.7
:C:\Python\Python36\python.exe
3.4
:C:\Python\Python34\python.exe
PEP 508 Information:
Powershell version:
System environment variables:
PIPENV_ACTIVE
PIP_DISABLE_PIP_VERSION_CHECK
PIP_PYTHON_PATH
PROMPT
PSMODULEPATH
PYTHONDONTWRITEBYTECODE
VIRTUAL_ENV
PIP_SHIMS_BASE_MODULE
PYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv?specific environment variables:
PIPENV_ACTIVE
:1
Debug?specific environment variables:
PATH
:...
VIRTUAL_ENV
:C:\Users\user1\.virtualenvs\foo-3kR5jZ-L
The text was updated successfully, but these errors were encountered: