From 79a73ef4aaa0f2c5a98ec837bf198dccf7d8c90f Mon Sep 17 00:00:00 2001 From: Matt Nicholson Date: Thu, 17 Aug 2017 10:45:45 -0400 Subject: [PATCH 1/3] add ability to force rbenv being shown --- README.md | 4 ++++ powerlevel9k.zsh-theme | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c17c2c5..c7d8b8e2 100644 --- a/README.md +++ b/README.md @@ -500,6 +500,10 @@ It figures out the version being used by taking the output of the `rbenv version * If `rbenv` is not in $PATH, nothing will be shown. * If the current Ruby version is the same as the global Ruby version, nothing will be shown. +Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show rbenv version, even if global| + ##### rspec_stats See [Unit Test Ratios](#unit-test-ratios), below. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3c34f0bb..dc2af025 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1047,11 +1047,15 @@ prompt_rbenv() { local rbenv_global="$(rbenv global)" # Don't show anything if the current Ruby is the same as the global Ruby. - if [[ $rbenv_version_name == $rbenv_global ]]; then - return + # Unless POWERLEVEL_RBENV_ALWAYS is set. + set_default POWERLEVEL9K_RBENV_ALWAYS false + if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then + "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + #elif [[ $rbenv_version_name != $rbenv_global ]]; then + # "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' + #else + # return fi - - "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' fi } From 095351cfe105acb48c1cd6874f4115bc50aaacbb Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Thu, 28 Sep 2017 17:24:39 -0400 Subject: [PATCH 2/3] Cleaning up README language about new `rbenv` feature. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7d8b8e2..3a40af61 100644 --- a/README.md +++ b/README.md @@ -498,11 +498,11 @@ This segment shows the version of Ruby being used when using `rbenv` to change y It figures out the version being used by taking the output of the `rbenv version-name` command. * If `rbenv` is not in $PATH, nothing will be shown. -* If the current Ruby version is the same as the global Ruby version, nothing will be shown. +* By default, if the current local Ruby version is the same as the global Ruby version, nothing will be shown. See the configuration variable, below, to modify this behavior. Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show rbenv version, even if global| +|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.| ##### rspec_stats From 748f9868fcf275a12359d23433191118ff690489 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Thu, 28 Sep 2017 17:27:59 -0400 Subject: [PATCH 3/3] Final cleanup for new POWERLEVEL9K_RBENV_ALWAYS flag --- powerlevel9k.zsh-theme | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dc2af025..d7d99c3f 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1041,20 +1041,16 @@ prompt_ram() { } # rbenv information +set_default POWERLEVEL9K_RBENV_ALWAYS false prompt_rbenv() { if which rbenv 2>/dev/null >&2; 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 POWERLEVEL_RBENV_ALWAYS is set. - set_default POWERLEVEL9K_RBENV_ALWAYS false + # Don't show anything if the current Ruby is the same as the global Ruby + # unless `POWERLEVEL9K_RBENV_ALWAYS` is set. if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' - #elif [[ $rbenv_version_name != $rbenv_global ]]; then - # "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON' - #else - # return fi fi }