summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme31
1 files changed, 20 insertions, 11 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index f171df10..73573a07 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1272,21 +1272,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
}
@@ -1640,11 +1638,22 @@ 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="system"
+ local pyenv_root="$(pyenv root)"
+ if [[ -f "${pyenv_root}/version" ]]; then
+ pyenv_global="$(pyenv version-file-read ${pyenv_root}/version)"
+ fi
+ 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
}