rvm.plugin.zsh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Completion
  2. fpath+=("${rvm_path}/scripts/zsh/Completion")
  3. typeset -g -A _comps
  4. autoload -Uz _rvm
  5. _comps[rvm]=_rvm
  6. # Aliases
  7. alias rubies='rvm list rubies'
  8. alias rvms='rvm gemset'
  9. alias gemsets='rvms list'
  10. # rb{version} utilities
  11. # From `rvm list known`
  12. typeset -A rubies
  13. rubies=(
  14. 18 'ruby-1.8.7'
  15. 19 'ruby-1.9.3'
  16. 20 'ruby-2.0.0'
  17. 21 'ruby-2.1'
  18. 22 'ruby-2.2'
  19. 23 'ruby-2.3'
  20. 24 'ruby-2.4'
  21. 25 'ruby-2.5'
  22. 26 'ruby-2.6'
  23. 27 'ruby-2.7'
  24. 30 'ruby-3.0'
  25. )
  26. for v in ${(k)rubies}; do
  27. version="${rubies[$v]}"
  28. functions[rb${v}]="rvm use ${version}\${1+"@\$1"}"
  29. functions[_rb${v}]="compadd \$(ls -1 \"\${rvm_path}/gems\" | grep '^${version}@' | sed -e 's/^${version}@//' | awk '{print $1}')"
  30. compdef _rb$v rb$v
  31. done
  32. unset rubies v version
  33. function rvm-update {
  34. rvm get head
  35. }
  36. # TODO: Make this usable w/o rvm.
  37. function gems {
  38. local current_ruby=`rvm-prompt i v p`
  39. local current_gemset=`rvm-prompt g`
  40. gem list $@ | sed -E \
  41. -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  42. -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  43. -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  44. -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  45. }