From 9446c7fb53b619993558d1ee602fac4fd5653ca0 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Mon, 4 Dec 2017 15:08:23 -0800 Subject: [PATCH] ruby-info: only run commands if the prompt needs the info --- modules/ruby/functions/ruby-info | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/modules/ruby/functions/ruby-info b/modules/ruby/functions/ruby-info index 7e64c27..cba0188 100644 --- a/modules/ruby/functions/ruby-info +++ b/modules/ruby/functions/ruby-info @@ -16,22 +16,23 @@ local version_formatted unset ruby_info typeset -gA ruby_info -if (( $+commands[rvm-prompt] )); then - version="$(rvm-prompt)" -elif (( $+commands[rbenv] )); then - version="$(rbenv version-name)" - if [[ $version == "system" ]]; then - version="" +# Grab formatting for anything we might have to do +zstyle -s ':prezto:module:ruby:info:version' format 'version_format' + +if [[ -n "$version_format" ]]; then + if (( $+commands[rvm-prompt] )); then + version="$(rvm-prompt)" + elif (( $+commands[rbenv] )); then + version="$(rbenv version-name)" + elif (( $+commands[ruby] )); then + version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" fi -elif (( $+commands[ruby] )); then - version="${${$(ruby --version)[(w)1,(w)2]}/ /-}" -fi -# Format version. -if [[ -n "$version" ]]; then - zstyle -s ':prezto:module:ruby:info:version' format 'version_format' - zformat -f version_formatted "$version_format" "v:$version" - ruby_info[version]="$version_formatted" + # Format version. + if [[ -n "$version" && "$version" != "system" ]]; then + zformat -f version_formatted "$version_format" "v:$version" + ruby_info[version]="$version_formatted" + fi fi # }