1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 11:38:00 +00:00

ruby-info: only run commands if the prompt needs the info

This commit is contained in:
Kaleb Elwert 2017-12-04 15:08:23 -08:00
parent 64d57ec71f
commit 3a0bd28e0c

View File

@ -16,22 +16,23 @@ local version_formatted
unset ruby_info unset ruby_info
typeset -gA ruby_info typeset -gA ruby_info
if (( $+commands[rvm-prompt] )); then # Grab formatting for anything we might have to do
version="$(rvm-prompt)" zstyle -s ':prezto:module:ruby:info:version' format 'version_format'
elif (( $+commands[rbenv] )); then
version="$(rbenv version-name)"
if [[ $version == "system" ]]; then
version=""
fi
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
fi
# Format version. if [[ -n "$version_format" ]]; then
if [[ -n "$version" ]]; then if (( $+commands[rvm-prompt] )); then
zstyle -s ':prezto:module:ruby:info:version' format 'version_format' version="$(rvm-prompt)"
zformat -f version_formatted "$version_format" "v:$version" elif (( $+commands[rbenv] )); then
ruby_info[version]="$version_formatted" version="$(rbenv version-name)"
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
fi
# Format version.
if [[ -n "$version" && "$version" != "system" ]]; then
zformat -f version_formatted "$version_format" "v:$version"
ruby_info[version]="$version_formatted"
fi
fi fi
# } # }