]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/rbfu/rbfu.plugin.zsh
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-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 || return
9
10 eval "$(rbfu --init --auto)"
11
12 # Internal: Print ruby version details, if it's currently active, etc.
13 function _rbfu_rubies_print() {
14   # 1: path to ruby file
15   # 2: active ruby
16   local rb rb_out
17   rb="${$1:t}"
18   rb_out="$rb"
19
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}"
23   fi
24
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}"
28   fi
29
30   echo $rb_out
31 }
32
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}"
39
40   _rbfu_rubies_print "${rbfu_dir}/system" "$active_rb"
41   for rb in ${rbfu_dir}/*(N); do
42     _rbfu_rubies_print "$rb" "$active_rb"
43   done
44 }
45
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/%/%%}" }