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
Allow option to display the $virtualenv differently, with more of $VIRTUAL_ENV as context #5889
Comments
So I got a custom command working (almost). The part in the [python] section isn't supported - I guess I would have to break out the top level format string, which seems complicated.
|
Maybe as an alternative solution: use [22:01:57] λ python -m venv .venv --prompt "whatever"
~/projects/whatever on feature/pagination (c2c6c249) v3.12.2 (venv:whatever) took 5s
[22:02:10] λ The first [python]
format = "[$symbol$version( \\(venv:$virtualenv\\))]($style) " |
Interesting. But what really motivated this was several times vscode somehow getting the venv wrong, or just changing directories. I'm sort of fine with what I already did. But I think it is a generally useful idea. I'm happy to close it if you think it's pointless, or not useful enough. As an aside, is there a way to do something like my custom command, or do I have to just rewrite the top level format string. Btw, starship is killer. |
And here's an example of how my (badly integrated) custom venv looks... ~/g/sample-python (0bdef92) 3? [🐍 v3.12.2]
08:53:46 ❯ . ./.venv/bin/activate
~/g/sample-python (0bdef92) 3? [🐍 v3.12.2](.venv)
08:53:59 ❯ cd ../tws-stack-deployment
~/g/tws-stack-deployment develop 2$ 1? [🐍 v3.12.2](sample-python/.venv)
08:54:20 ❯ . .venv/bin/activate
~/g/tws-stack-deployment develop 2$ 1? [🐍 v3.12.2](.venv)
08:54:26 ❯ cd -
~/git/sample-python
~/g/sample-python (0bdef92) 3? [🐍 v3.12.2](tws-stack-deployment/.venv) Could keep all the config the same (just change the behavior of $virtualenv) or maybe add a flag option like warn_by_qualifying_virtualenv_with_directory_when_it_seems_like_it_might_be_wrong_venv: true Again, starship is a great package, I'm fine if you prefer to "close won't fix". If I can figure out the proper way to include it in the [python] configuration, I'll add it to that issue for examples of custom scripts. |
Just want to +1 this, stumbled upon this after dealing with the same issue as @marvingreenberg. I'd love the ability to show a bit more information about the virtualenv - I name all of mine Edit: Maybe another potential solution would be showing the value in a certain environment variable, such as VENV_NAME or VENV_PROMPT or STARSHIP_VENV_{NAME/PROMPT} - that would let users set this on their own using whatever logic they want |
@marvingreenberg BTW your config works well enough for me, thank you for sharing it, I can finally stop wasting time finding a way to warn myself when I'm in the wrong one |
Feature Request
Is your feature request related to a problem? Please describe.
The $virtualenv tag in python projects pretty much always says (.venv) since the .venv dir is always called that. The problem is that switching directories and things you can get into a situation where you are using the wrong venv. And various IDEs automatically set venv (Im looking at you vscode) so the shells that get opened may not be what you expect.
Here, my shell is using the venv from some other project... Not what is wanted.
Describe the solution you'd like
A setting to modify how $virtualenv behaves, instead of just displaying .venv (or whatever the .venv dir is?)
(tws-stack-deployment/.venv)
(tws-…ment/.venv)
when VIRTUAL_ENV and current dir (or subdir) seems consistent with the PWD
Or some combination of one or more of those. The last one is not immediately obvious exactly how to check
if the VIRTUAL_ENV is "consistent". With the first and third implemented, implementing the second is much less important and maybe even undesirable? Obviously more thought to the option name(s) to be consistent with existing styles/practice
Describe alternatives you've considered
I know (I think) I can write a custom tag (sic) to format the appropriate info from the VIRTUAL_ENV env var (although I tried a few iteraions unsuccessfully, so far). But this seems to be a reasonable useful feature to have builtin.
The text was updated successfully, but these errors were encountered: