rvm.plugin.zsh 1.2 KB

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