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

venv: Make activate et al. export custom prompt prefix as an envvar #89427

Closed
jwodder mannequin opened this issue Sep 22, 2021 · 1 comment
Closed

venv: Make activate et al. export custom prompt prefix as an envvar #89427

jwodder mannequin opened this issue Sep 22, 2021 · 1 comment
Labels
3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@jwodder
Copy link
Mannequin

jwodder mannequin commented Sep 22, 2021

BPO 45264
Nosy @jwodder

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-09-22.15:23:41.614>
labels = ['type-feature', 'library', '3.11']
title = 'venv: Make activate et al. export custom prompt prefix as an envvar'
updated_at = <Date 2021-09-22.15:23:41.614>
user = 'https://github.com/jwodder'

bugs.python.org fields:

activity = <Date 2021-09-22.15:23:41.614>
actor = 'jwodder'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-09-22.15:23:41.614>
creator = 'jwodder'
dependencies = []
files = []
hgrepos = []
issue_num = 45264
keywords = []
message_count = 1.0
messages = ['402444']
nosy_count = 1.0
nosy_names = ['jwodder']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue45264'
versions = ['Python 3.11']

Linked PRs

@jwodder
Copy link
Mannequin Author

jwodder mannequin commented Sep 22, 2021

I use a custom script (and I'm sure many others have similar scripts as well) for setting my prompt in Bash. It shows the name of the current venv (if any) by querying the VIRTUAL_ENV environment variable, but if the venv was created with a custom --prompt, it is unable to use this prompt prefix, as the activate script does not make this information available.

I thus suggest that the activate et al. scripts should set and export an environment variable named something like VIRTUAL_ENV_PROMPT_PREFIX that contains the prompt prefix (either custom or default) that venv would prepend to the prompt. Ideally, this should be set even when VIRTUAL_ENV_DISABLE_PROMPT is set in case the user wants total control over their prompt.

(This was originally posted as an issue for virtualenv at <https://github.com/pypa/virtualenv/issues/2194\>, and it was suggested to post it here for feedback.)

@jwodder jwodder mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 22, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@vsajip vsajip added 3.13 new features, bugs and security fixes and removed 3.11 only security fixes labels Jul 12, 2023
@vsajip vsajip closed this as completed Jul 13, 2023
vsajip pushed a commit that referenced this issue Jan 23, 2024
…H-106726)

This improves the implementation in gh-106643.

Previously, venv passed "(<prompt>) " to the activation scripts, but we want
to provide the original value so that users can inspect it in the
$VIRTUAL_ENV_PROMPT env var.

Note: Lib/venv/scripts/common/Activate.ps1 surrounded the prompt value with
parens a second time, so no change was necessary in that file.
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…MPT (pythonGH-106726)

This improves the implementation in pythongh-106643.

Previously, venv passed "(<prompt>) " to the activation scripts, but we want
to provide the original value so that users can inspect it in the
$VIRTUAL_ENV_PROMPT env var.

Note: Lib/venv/scripts/common/Activate.ps1 surrounded the prompt value with
parens a second time, so no change was necessary in that file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant