Skip to content
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

Prompt virtualenv name does not respect Python's venv --prompt argument #539

Open
2 tasks
paw-lu opened this issue Mar 27, 2020 · 7 comments
Open
2 tasks

Comments

@paw-lu
Copy link

paw-lu commented Mar 27, 2020

General information

System report (output of prompt_pure_system_report):

  • Zsh: zsh 5.3 (x86_64-apple-darwin18.0)
  • Operating system: Mac OS X 10.14.4 (18E226)
  • Terminal program: Hyper (3.0.2)
  • Git: git version 2.25.0
  • Pure state:
    • username: ''
    • prompt:
    • version: 1.10.3
  • Virtualenv: export VIRTUAL_ENV_DISABLE_PROMPT=12
  • Prompt: typeset -g PROMPT=$'%F{${prompt_pure_colors[path]}}%~%f %F{248}${prompt_pure_vcs_info[branch]}%F{13}${prompt_pure_git_dirty}%f %{ %}%(12V.%F{$prompt_pure_colors[virtualenv]}%12v%f .)%(?.%F{$prompt_pure_colors[prompt:success]}.%F{$prompt_pure_colors[prompt:error]})${prompt_pure_state[prompt]}%f '
  • Detected frameworks: Oh My Zsh
    • Oh My Zsh:
      • Plugins: git, osx, python, pip, conda-zsh-completion, poetry, docker, docker-compose, zsh-autosuggestions

Other information

I have:

  • Tested with another terminal program and can reproduce the issue:
  • Followed the integration instructions for my framework

Problem description

Python's venv has an optional argument where you may specify a prompt prefix via --prompt. I expect this name to be reflected in the prompt. When activating the pure theme, it does not respect the --prompt name and instead uses the directory name.

Reproduction steps

With pure theme

❯ python -m venv --prompt test .venv

❯ source .venv/bin/activate

.venv ❯

Without pure theme

% source .venv/bin/activate
(test) % 
@mafredri
Copy link
Collaborator

Not sure what we can do here, this information isn't available via environment variables, so there's no good way for us to detect the custom prompt 😞.

@paw-lu
Copy link
Author

paw-lu commented Mar 27, 2020

Ah, you're correct. Found this Python issue discussing that.

I do know it does work on powerlevel10k—addressed in this issue—though it's not clear to me how they achieve it.

@mafredri
Copy link
Collaborator

mafredri commented Mar 28, 2020

Ok, looks like p10k has a whitelist for "generic" virtualenv names, if it detects one than it uses the name of the parent folder. For instance: ~/test/.venv tests postive for "generic" name, in which case they pick test from the parent directory instead.

If we go this same route, I'm hoping we can avoid maintaining a list of generic names but perhaps we could allow the user to define one. I don't know if anyone really wants to name their virtualenv .venv, but I'd hate to remove that option. Ideally this should be solved by python virtualenv.

@romkatv
Copy link
Contributor

romkatv commented Mar 28, 2020

It's configurable in p10k. Here's the parameter's default value:

typeset -g POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES=(virtualenv venv .venv env)

@mafredri
Copy link
Collaborator

mafredri commented Sep 19, 2020

Looks like some support for this has landed in python/cpython#21587 but unfortunately it won't be of any use to us 😞.

It doesn't actually set the new variable, VIRTUAL_ENV_PROMPT, when VIRTUAL_ENV_DISABLE_PROMPT is set, even though it does set VIRTUAL_ENV.

@mafredri
Copy link
Collaborator

I submitted a PR to address this, let's see how it goes: python/cpython#22324

@paw-lu
Copy link
Author

paw-lu commented Sep 21, 2020

It doesn't actually set the new variable, VIRTUAL_ENV_PROMPT, when VIRTUAL_ENV_DISABLE_PROMPT is set, even though it does set VIRTUAL_ENV.

so close... 😅

good luck on the PR! and thanks for writing it up! so many prompts would benefit from this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants