1
0
mirror of https://github.com/artizirk/dotfiles.git synced 2024-12-22 03:20:15 +02:00

Always read custom venv prompt from config file

And ignore VIRTUAL_ENV_PROMPT variable for now as it is different
between venv and virtualenv implementations:

* https://github.com/python/cpython/pull/106726
* https://github.com/pypa/virtualenv/pull/2606
This commit is contained in:
Arti Zirk 2024-10-29 16:21:14 +02:00
parent ee48d1a87a
commit e50989e39a

7
.zshrc
View File

@ -5,11 +5,8 @@ zmodload zsh/pcre
# Virtualenv support # Virtualenv support
function _virtual_env_prompt () { function _virtual_env_prompt () {
# new pyvenv has a seperate variable for custom prompt value
REPLY=${VIRTUAL_ENV_PROMPT+${VIRTUAL_ENV_PROMPT}}
# Try to read the prompt name form pyvenv.cfg # Try to read the prompt name form pyvenv.cfg
if [[ -z "${REPLY}" && -f "$VIRTUAL_ENV/pyvenv.cfg" ]]; then if [[ -f "$VIRTUAL_ENV/pyvenv.cfg" ]]; then
# Matches lines with following syntax # Matches lines with following syntax
# prompt = 'cool prompt' # prompt = 'cool prompt'
# prompt = "cool prompt" # prompt = "cool prompt"
@ -32,7 +29,7 @@ function _virtual_env_prompt () {
fi fi
fi fi
# support old-school virtualenv # fall back to using venv folder name as prompt name
if [[ -z "${REPLY}" ]]; then if [[ -z "${REPLY}" ]]; then
REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) } REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
fi fi