Open max-santiago opened 6 months ago
I'm personally not a big fan of tools updating my PS1. I'd be open to this being optional functionality, but for me personally this is something I'd rather have configured in custom PS1 logic in my own rc file or with something like starship.
Got it! Thanks for the clarification. Ideally, I'd like the PS update logic to run on activation/deactivation of the environment rather than when starting up the shell or on changing directories. I actually had a custom rc file which did this in a single step, and I was able to, e.g. reference the VIRTUAL_ENV variable after it was set within my code when updating PS1.
It is unclear to me how/where I could add a "hook" that updates PS1 after mise
activates/deactivates the environment. Apologies in advance if this is a bit basic. I'll look into starship in the meantime!
when I have pyenv and pyenv-virtualenv activate my environment, those are done with commands added to my zshrc or zprofile. The commands are
.zprofile:
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
.zshrc:
eval "$(pyenv virtualenv-init -)"
Are there similar commands we could use to enable this behavior in our rc and profile files? This would allow users to opt into this functionality which would be provided as a first-party solution by mise while still following @jdx's opinion of not having mise itself directly update PS1 as a default behavior.
the blog works for me: https://barker.codes/blog/adding-the-virtual-environment-name-to-your-prompt-with-oh-my-zsh/
Usually, when activating a Python virtual environment (whether manually or with virtual environment management tools such as
direnv
orautoenv
), theVIRTUAL_ENV
environment variable is set, and thePS1
variable will be overridden to display the virtual environment name in the shell.I noticed that the auto-activation logic from
jdx
will correctly setVIRTUAL_ENV
and point thepython
command to the correct executable, but it won't update thePS1
variable to show the environment name in the shell prompt, which is what I would expect to happen when activating an environment (whether manually or automatically with tools such as direnv or autoenv).I think the relevant code snippet from the generic
activate
script is the following:It would be nice to have
mise
updatePS1
and restore it back to normal as it activates and deactivates Python environments whenever I switch directories on the shell.