Skip to content
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

themes/agnoster : pyenv not properly detected/shown #458

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

Epithumia
Copy link
Contributor

At the moment, agnoster relies on $VIRTUAL_ENV to detect virtualenvs, but it is unreliable when using pyenv. With a named pyenv virtualenv, it properly detects we are in a virtualenv, and sets the prompt as [v] <version>; when using a non-system version, it fails to detect the version ($VIRTUAL_ENV is not set) and hides the python segment.

Ideally (I think), pyenv should be treated and displayed somewhat like conda is: when a non system version is used, grab the python version, and when in a virtualenv, show its name and version.

This PR adds Pyenv detection to agnoster:

  • if pyenv is not initialized, fall back to the virtualenv detection
  • when pyenv is set to a version other than "system", show the version number
  • when pyenv is in virtulenv mode, also display the virtualenv's name

I'm not particularly proficient with bash, so the whole thing can probably be improved, but as far as I could test, it works. Since I don't use conda, it would likely require some extra testing to see how the two interact and check that it doesn't break the conda display.

Add Pyenv detection to agnoster:

 - if pyenv is not initialized, fall back to the virtualenv detection
 - when pyenv is set to a version other than "system", show the version number
 - when pyenv is in virtulenv mode, also display the virtualenv's name
Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! Could you check the following comments?

Also, you might want to submit similar changes to the upstream speedenator/agnoster-bash.

themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
Epithumia and others added 2 commits July 25, 2023 14:41
Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for updating! These are the second round of comments.

themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
themes/agnoster/agnoster.theme.sh Outdated Show resolved Hide resolved
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
@Epithumia
Copy link
Contributor Author

I tested both suggestions, seems fine as far as I can tell, so I added both.

Copy link
Contributor

@akinomyoga akinomyoga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@akinomyoga akinomyoga merged commit 9c9c92b into ohmybash:master Jul 26, 2023
4 checks passed
@Epithumia
Copy link
Contributor Author

Thank you for the comments and suggestions. ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants