1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-19 14:01:57 +00:00

Improve rbenv as well

This commit is contained in:
Alexara Wu 2018-07-14 17:09:56 +08:00
parent 25e2064f0e
commit 9f09547ad1
No known key found for this signature in database
GPG key ID: 20807CF3A407E38D

View file

@ -1262,19 +1262,17 @@ prompt_ram() {
################################################################ ################################################################
# Segment to display rbenv information # Segment to display rbenv information
# https://github.com/rbenv/rbenv#choosing-the-ruby-version
set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false
prompt_rbenv() { prompt_rbenv() {
if [ $commands[rbenv] ]; 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_version_name="$(rbenv version-name)"
local rbenv_global="$(rbenv global)" local rbenv_global="$(rbenv global)"
if ! [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then
# Don't show anything if the current Ruby is the same as the global Ruby "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
# unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set.
if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then
return
fi fi
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi fi
} }
@ -1632,15 +1630,12 @@ prompt_virtualenv() {
# https://github.com/pyenv/pyenv#choosing-the-python-version # https://github.com/pyenv/pyenv#choosing-the-python-version
set_default POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW false set_default POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW false
prompt_pyenv() { prompt_pyenv() {
if [ $commands[pyenv] ]; then if [[ -n "$PYENV_VERSION" ]]; then
if [[ -n "$PYENV_VERSION" ]]; then "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON'
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON' elif [ $commands[pyenv] ]; then
else local pyenv_version_name="$(pyenv version-name)"
local pyenv_version_name="$(pyenv version-name)" local pyenv_global="$(pyenv version-file-read $(pyenv root)/version)"
local pyenv_global="$(pyenv version-file-read $(pyenv root)/version)" if ! [[ $pyenv_version_name == $pyenv_global && "$POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW" = false ]]; then
if [[ $pyenv_version_name == $pyenv_global && "$POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW" = false ]]; then
return
fi
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version_name" 'PYTHON_ICON' "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version_name" 'PYTHON_ICON'
fi fi
fi fi