rvm.plugin.zsh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. 31 'ruby-3.1'
  26. )
  27. for v in ${(k)rubies}; do
  28. version="${rubies[$v]}"
  29. functions[rb${v}]="rvm use ${version}\${1+"@\$1"}"
  30. functions[_rb${v}]="compadd \$(ls -1 \"\${rvm_path}/gems\" | grep '^${version}@' | sed -e 's/^${version}@//' | awk '{print $1}')"
  31. compdef _rb$v rb$v
  32. done
  33. unset rubies v version
  34. function rvm-update {
  35. rvm get head
  36. }
  37. # TODO: Make this usable w/o rvm.
  38. function gems {
  39. local current_ruby=`rvm-prompt i v p`
  40. local current_gemset=`rvm-prompt g`
  41. gem list $@ | sed -E \
  42. -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  43. -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  44. -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  45. -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  46. }