diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2018-07-16 18:01:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-16 18:01:00 +0300 |
commit | 22a761208d24027a26daa947a7b4034365fefc16 (patch) | |
tree | ccfac74e0a95da5c4a3e41b900b179fdb047d66c /powerlevel9k.zsh-theme | |
parent | a7b3f310d3c1e5306332dd15401efb9631c76bed (diff) | |
parent | 45fe401dc249c14ba6459faa5358d248baa63df8 (diff) |
Merge pull request #900 from AlexaraWu/patch/pyenv
Fix `pyenv` segment
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f3126b81..3e425c48 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1260,21 +1260,19 @@ prompt_ram() { "$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON' } - +################################################################ +# Segment to display rbenv information +# https://github.com/rbenv/rbenv#choosing-the-ruby-version set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false -# rbenv information prompt_rbenv() { - if command which rbenv 2>/dev/null >&2; then + if [[ -n "$RBENV_VERSION" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$RBENV_VERSION" 'RUBY_ICON' + elif [ $commands[rbenv] ]; then local rbenv_version_name="$(rbenv version-name)" local rbenv_global="$(rbenv global)" - - # Don't show anything if the current Ruby is the same as the global Ruby - # unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set. - if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then - return + if [[ "${rbenv_version_name}" != "${rbenv_global}" || "${POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW}" == "true" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi - - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi } @@ -1628,11 +1626,18 @@ prompt_virtualenv() { } ################################################################ -# pyenv: current active python version (with restrictions) +# Segment to display pyenv information # https://github.com/pyenv/pyenv#choosing-the-python-version +set_default POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW false prompt_pyenv() { if [[ -n "$PYENV_VERSION" ]]; then "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' + elif [ $commands[pyenv] ]; then + local pyenv_version_name="$(pyenv version-name)" + local pyenv_global="$(pyenv version-file-read $(pyenv root)/version)" + if [[ "${pyenv_version_name}" != "${pyenv_global}" || "${POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW}" == "true" ]]; then + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version_name" 'PYTHON_ICON' + fi fi } |