Customizable venv prompt prefix and suffix
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
In venv activate PS1 is updated with the fixed format.
Some user like me doesn't like such format for some reason.
For my case, I'd like to keep empty line between the previous output and the current prompt like
[/tmp]
<username>@<hostname>% python --version
Python 3.14.2
[/tmp]
<username>@<hostname>%
If I enable venv, it breaks my preference like
(.python.venv.default.3.14.2)
[/tmp]
<username>@<hostname>% python --version
Python 3.14.2
(.python.venv.default.3.14.2)
[/tmp]
<username>@<hostname>%
I want to keep empty like between previous output and commands like
(.python.venv.default.3.14.2)
[/tmp]
<username>@<hostname>% python --version
Python 3.14.2
(.python.venv.default.3.14.2)
[/tmp]
<username>@<hostname>%
This can be easily achieved keeping the compatibility by taking prefix and suffix for venv name in activate to set PS1 instaed of current "(" and ") ".
It makes someone to use explain venv name as their preferred way like
(Python env: /home/<...>/.venv)
[/tmp]
<username>@<hostname>% python --version
Python 3.14.2
(Python env: /home/<...>/.venv)
[/tmp]
<username>@<hostname>%
with
# Auto activate .venv in the new dir
function chpwd() {
if [[ -d "`pwd`/.venv" ]]; then
VIRTUAL_ENV_PROMPT_PREFIX="
(Python env: `pwd`/" source `pwd`/.venv/bin/activate
fi
}
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-144205
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the venv activate script referenced in the proposal and review how it currently sets PS1. Compare the requested configurable prefix and suffix behavior with the linked work in gh-144205; done means preserving the existing default while allowing the prompt format shown in the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100