1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prezto/modules/ruby/functions/ruby-info

35 lines
827 B

#
# Exposes information about the Ruby environment via the $ruby_info associative
# array.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local version
local version_format
local version_formatted
local version_manager
# Clean up previous $ruby_info.
unset ruby_info
typeset -gA ruby_info
if (( $+commands[rvm-prompt] )); then
version="$(rvm-prompt)"
version_manager="rvm"
elif (( $+commands[rbenv] )); then
version="$(rbenv version-name)"
version_manager="rbenv"
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
version_manager="ruby"
fi
# Format version.
if [[ -n "$version" ]]; then
zstyle -s ':prezto:module:ruby:info:version' format 'version_format'
zformat -a version_formatted ":" "$version_manager:$version"
ruby_info[version]="$version_formatted"
fi