1 # Enables rbfu with --auto option, if available.
3 # Also provides a command to list all installed/available
4 # rubies. To ensure compatibility with themes, creates the
5 # rvm_prompt_info function to return the $RBFU_RUBY_VERSION
8 command -v rbfu &>/dev/null || return
10 eval "$(rbfu --init --auto)"
12 # Internal: Print ruby version details, if it's currently active, etc.
13 function _rbfu_rubies_print() {
14 # 1: path to ruby file
20 # If the ruby is a symlink, add @ to the name.
21 if [[ -h "$1" ]]; then
22 rb_out="${rb_out}${fg[green]}@${reset_color}"
25 # If the ruby is active, add * to the name and show it in red.
26 if [[ "$rb" = "$2" ]]; then
27 rb_out="${fg[red]}${rb_out} ${fg[red]}*${reset_color}"
33 # Public: Provide a list with all available rubies, this basically depends
34 # on ~/.rfbu/rubies. Highlights the currently active ruby version and aliases.
35 function rbfu-rubies() {
36 local rbfu_dir active_rb
37 rbfu_dir="${RBFU_RUBIES:-${HOME}/.rbfu/rubies}"
38 active_rb="${RBFU_RUBY_VERSION:-system}"
40 _rbfu_rubies_print "${rbfu_dir}/system" "$active_rb"
41 for rb in ${rbfu_dir}/*(N); do
42 _rbfu_rubies_print "$rb" "$active_rb"
46 # Public: Create rvm_prompt_info command for themes compatibility, unless
47 # it has already been defined.
48 (( ${+functions[rvm_prompt_info]} )) || \
49 function rvm_prompt_info() { echo "${${RBFU_RUBY_VERSION:=system}:gs/%/%%}" }