Closed gumikola closed 4 years ago
It looks as if that should not be at all hard to accomplish. Give me a couple of days and I'll throw something together and you can try it out for me.
Try out what I've got on the venv
branch. I added a simple indicator for virtualenv
and conda
. If it works for you, I'll continue to work on it a bit. (Note that it won't work out of the box if you're using an advanced custom prompt, although it can be made to work, of course.)
Work like a charm! Miss only docs how to change position because I prefer indicator after git status despite this is still very useful. Thank you.
I'm so glad you like it, and thanks so much for encouraging me to add this needed feature.
The trick about the positioning of the prompt elements is this: the Git status is the only asynchronous one, meaning that it will always appear just a moment after everything else. For that reason, I'll probably never make a simple setting that will have it pop up between the path and the virtualenv
indicator -- the effect of the prompt being redrawn just looks to ugly to me.
But give the following settings a try. It may turn out that you're only working on really fast machines -- in that case, you may not mind the redrawing effect much:
# Exit status
AGKOZAK_CUSTOM_PROMPT='%(?..%B%F{red}(%?%)%f%b )'
# Command execution time (probably moving to this position in next version of
# agkozak-zsh-prompt)
AGKOZAK_CUSTOM_PROMPT+='%(9V.%9v .)'
# Path
AGKOZAK_CUSTOM_PROMPT+='%B%F{blue}%2v%f%b'
# Git status (followed by newline)
AGKOZAK_CUSTOM_PROMPT+='%(3V.%F{243}%3v%f.)'
# virtualenv/conda indicator
AGKOZAK_CUSTOM_PROMPT+=$'%(10V. %F{${AGKOZAK_COLORS_VENV:-green}}[%10v]%f.)\n'
# Prompt character
AGKOZAK_CUSTOM_PROMPT+='%F{magenta}%(4V.❮.❯)%f '
# Right prompt is empty
AGKOZAK_CUSTOM_RPROMPT=''
You'll see that the prompt string %10v
is the one that contains the virtualenv
name.
I'll keep working on the new version of the prompt. It might not come out for a few weeks, so you can keep using this branch. If I make any changes to how it works, I'll let you know here. Let me know if you have any more suggestions.
I think I've got it working for pipenv
, too.
With poetry
works too. Thanks for the effort. The position of indicator is not important.
It looks as if poetry
appends a hash and a python
version to the name of the virtualenv directory, e.g.
[poetry-demo-uyC2R89H-py3.7]
I ran into a similar problem with pipenv
. I've committed a fix so that the garble doesn't show.
I've also got the prompt handling situations when
poetry config virtualenvs.in-project true
has been set.
Work very well. Thank you. I think can you close the ticket and merge to master :)
Thanks again for your help in improving the prompt. I will update the documentation and add a demo for the new feature and release a new version of the prompt in the next few days.
All right, I just released this feature in v3.7.0
on the master branch. I added an array AGKOZAK_VIRTUALENV_CHARS
, which can specify the characters to display around the virtual environment indicator (default: ( '[' ']' )
.
Hi. I wanna switch from Pure theme completely to agkozak-zsh-prompt but stopping me from this is a lack of prompt virtualenv. Can you add this indicator in the future?