my xfce4 dotfiles
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.

49 lines
1.4 KiB

3 years ago
  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. command -v rbfu &>/dev/null || return
  8. eval "$(rbfu --init --auto)"
  9. # Internal: Print ruby version details, if it's currently active, etc.
  10. function _rbfu_rubies_print() {
  11. # 1: path to ruby file
  12. # 2: active ruby
  13. local rb rb_out
  14. rb="${$1:t}"
  15. rb_out="$rb"
  16. # If the ruby is a symlink, add @ to the name.
  17. if [[ -h "$1" ]]; then
  18. rb_out="${rb_out}${fg[green]}@${reset_color}"
  19. fi
  20. # If the ruby is active, add * to the name and show it in red.
  21. if [[ "$rb" = "$2" ]]; then
  22. rb_out="${fg[red]}${rb_out} ${fg[red]}*${reset_color}"
  23. fi
  24. echo $rb_out
  25. }
  26. # Public: Provide a list with all available rubies, this basically depends
  27. # on ~/.rfbu/rubies. Highlights the currently active ruby version and aliases.
  28. function rbfu-rubies() {
  29. local rbfu_dir active_rb
  30. rbfu_dir="${RBFU_RUBIES:-${HOME}/.rbfu/rubies}"
  31. active_rb="${RBFU_RUBY_VERSION:-system}"
  32. _rbfu_rubies_print "${rbfu_dir}/system" "$active_rb"
  33. for rb in ${rbfu_dir}/*(N); do
  34. _rbfu_rubies_print "$rb" "$active_rb"
  35. done
  36. }
  37. # Public: Create rvm_prompt_info command for themes compatibility, unless
  38. # it has already been defined.
  39. (( ${+functions[rvm_prompt_info]} )) || \
  40. function rvm_prompt_info() { echo "${${RBFU_RUBY_VERSION:=system}:gs/%/%%}" }