New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add virtualenv support to bobthefish powerbar theme #144
Conversation
If VIRTUAL_ENV envvar is set, then prefix the basename in blue to the start of the powerbar Also set the VIRTUAL_ENV_DISABLE_PROMPT envvar to stop virtualenv from adding its own prefix Currently an issue when entering a virtualenv, because the fish script to enter a virtualenv returns non-zero exit status when VIRTUAL_ENV_DISABLE_PROMPT is set, but this is a minor issue that can be solved by virtualenv patch.
Added a trailing space to even up the output
@bobthecow What do you think? |
@@ -169,6 +169,12 @@ function __bobthefish_prompt_status -d 'the symbols for a non zero exit status, | |||
set bg_jobs $bg_job_glyph | |||
end | |||
|
|||
set -gx VIRTUAL_ENV_DISABLE_PROMPT true | |||
if test "$VIRTUAL_ENV" | |||
__bobthefish_start_segment blue fff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use $slate_blue
here to keep with the color palette?
I don't use virtualenv, but I am not the least bit opposed :) It does seem like that should go after the flags rather than before, though. |
This actually shouldn't be inside the Let's pull the whole virtualenv logic out into its own function ( |
Thanks for joining the conversation @bobthecow! |
@bpinto No problem :) On second thought, I'd put it after the call to |
@stestagg Are you around? |
I have a branch on my fork with this plus my changes (but rebased against the current bobthefish). https://github.com/bobthecow/oh-my-fish/compare/virtualenv I'm a bit worried about that |
Sorry for the delayed response from me, I've had other things on. I'm starting to think that powerline functionality should be abstracted so it's simpler to create custom powerlines, but again, separate issue. as for the global environment, the original pull request: pypa/virtualenv#5 was for this exact reason, to allow someone to have a custom prompt, I'd suggest this is a very safe default behaviour to follow. Thanks for picking this up, and your changes. Steve |
If you want to override the order, you could source the original theme then redefine function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set -g RETVAL $status
__bobthefish_prompt_status
__bobthefish_prompt_user
__bobthefish_prompt_virtualenv
if __bobthefish_in_git
__bobthefish_prompt_git
else
__bobthefish_prompt_dir
end
__bobthefish_finish_segments
end For what it's worth, though, the only thing you'll usually see in front of your virtualenv segment is the
Fair enough. Is there anything in the environment we can check to see whether someone is actually using virtualenv, so that we don't litter everyone else's global environment with a flag to disable something they're not even using? |
That's a fair point about not seeing the 'user' by default, I hadn't checked back about that.. As for your question about the env var, I don't know how simple this will be. The virtualenv script that is run is here: https://github.com/pypa/virtualenv/blob/develop/virtualenv_embedded/activate.fish The problem is that when the activate.fish script is run, it's at script run time that it looks for the $VIRTUAL_ENV_DISABLE_PROMPT environment as a one-off, and then replaces the fish_prompt function with a wrapper func that prints it's virtualenv prefix first. Once this wrapping happens, it's set until the 'deactivate' function is called to break out of the virtualenv (some time in the future) The only way I can see to be dynamic about this would be to detect when a virtualenv has just been activated, and replace the fish_prompt function with the original, but that would be quite complex, imo. There might be a simpler way, but it eludes me right now |
Given that it's a one-off check, |
If VIRTUAL_ENV envvar is set, then prefix the basename in blue to the start of the powerbar
Also set the VIRTUAL_ENV_DISABLE_PROMPT envvar to stop virtualenv from adding its own prefix
Currently an issue when entering a virtualenv, because the fish script to enter a virtualenv returns non-zero exit status when VIRTUAL_ENV_DISABLE_PROMPT is set, but this is a minor issue that can be solved by virtualenv patch.