]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/rbfu/rbfu.plugin.zsh
0084852054d3c78856b24187a2e485d02b5e04c8
[dotfiles.git] / zsh / plugins / rbfu / rbfu.plugin.zsh
1 # Enables rbfu with --auto option, if available.
2 #
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
6 # version.
7
8 command -v rbfu &>/dev/null
9
10 if [[ $? -eq 0 ]]; then
11 eval "$(rbfu --init --auto)"
12
13 # Internal: Print ruby version details, if it's currently
14 # active etc.
15 function _rbfu_rubies_print() {
16 local rb rb_out
17 rb=$(basename $1)
18 rb_out="$rb"
19 [[ -h $1 ]] && rb_out="$rb_out${fg[green]}@${reset_color}"
20 [[ "x$rb" == "x$2" ]] && rb_out="${fg[red]}$rb_out ${fg[red]}*${reset_color}"
21 echo $rb_out
22 }
23
24 # Public: Provide a list with all available rubies, this basically depends
25 # on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version
26 # and aliases.
27 function rbfu-rubies() {
28 local rbfu_dir active_rb
29 rbfu_dir=$RBFU_RUBIES
30 active_rb=$RBFU_RUBY_VERSION
31 [[ -z "$rbfu_dir" ]] && rbfu_dir="${HOME}/.rbfu/rubies"
32 [[ -z "$active_rb" ]] && active_rb="system"
33 _rbfu_rubies_print "${rbfu_dir}/system" $active_rb
34 for rb in $(ls -1 $rbfu_dir); do
35 _rbfu_rubies_print "${rbfu_dir}/${rb}" $active_rb
36 done
37 }
38
39 # Public: Create rvm_prompt_info command for themes compatibility, unless
40 # it has already been defined.
41 [ ! -x rvm_prompt_info ] && function rvm_prompt_info() { echo "${RBFU_RUBY_VERSION:=system}" }
42 fi