I have tried to customize my virtual environment prompt by adding the following to my .zshrc file:
...
export VIRTUAL_ENV_DISABLE_PROMPT=1
if [[ -v VIRTUAL_ENV ]]; then
PROMPT='%F{green}(venv)%f'$PROMPT
fi
...
This only works if i $ source ~/.zshrc after activating a virtual environment.
I made it work automatically by adding the aliases below, but I was wondering if there is a better way to make this work automatically?
alias venv='source ./venv/bin/activate; source ~/.zshrc'
alias deactivate='deactivate; source ~/.zshrc'
Perhaps a simple way for your case would be to define the prompt as
If VIRTUAL_ENV is set during evaluation of the prompt, the
+causes $vprompt to be printed in front of your original prompt. If VIRTUAL_ENV is unset, nothing is printed, and you only get your original prompt.