From 78e78f6d0b287efca65c76c4247d771fc1ee4c7d Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 20 Jun 2019 09:21:29 +0200 Subject: [PATCH] simplify chruby --- internal/p10k.zsh | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index ca7cc66c..3a90941e 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1341,23 +1341,11 @@ prompt_rbenv() { set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true prompt_chruby() { - # Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby - local chruby_label="" - - if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then - chruby_label+="$RUBY_ENGINE " - fi - if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then - chruby_label+="$RUBY_VERSION" - fi - - # Truncate trailing spaces - chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}" - - # Don't show anything if the chruby did not change the default ruby - if [[ "$RUBY_ENGINE" != "" ]]; then - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" 'RUBY_ICON' 0 '' "${${chruby_label//\%/%%}//\\/\\\\}" - fi + [[ -n $RUBY_ENGINE ]] || return + local v='' + [[ $POWERLEVEL9K_CHRUBY_SHOW_ENGINE == true ]] && v=$RUBY_ENGINE + if [[ $POWERLEVEL9K_CHRUBY_SHOW_VERSION == true && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" 'RUBY_ICON' 0 '' "${${v//\%/%%}//\\/\\\\}" } ################################################################