Customizable venv prompt prefix and suffix
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從提案中引用的 venv 啟用腳本開始,檢查它目前如何設定 PS1。將所要求的可設定前綴和後綴行為與 gh-144205 中連結的工作進行比較;完成標準是在保留現有預設行為的同時,允許使用範例中所示的提示字元格式。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100