rvm.plugin.zsh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. fpath=($rvm_path/scripts/zsh/Completion $fpath)
  2. alias rubies='rvm list rubies'
  3. alias gemsets='rvm gemset list'
  4. local ruby18='ruby-1.8.7'
  5. local ruby19='ruby-1.9.3'
  6. local ruby20='ruby-2.0.0'
  7. function rb18 {
  8. if [ -z "$1" ]; then
  9. rvm use "$ruby18"
  10. else
  11. rvm use "$ruby18@$1"
  12. fi
  13. }
  14. _rb18() {compadd `ls -1 $rvm_path/gems | grep "^$ruby18@" | sed -e "s/^$ruby18@//" | awk '{print $1}'`}
  15. compdef _rb18 rb18
  16. function rb19 {
  17. if [ -z "$1" ]; then
  18. rvm use "$ruby19"
  19. else
  20. rvm use "$ruby19@$1"
  21. fi
  22. }
  23. _rb19() {compadd `ls -1 $rvm_path/gems | grep "^$ruby19@" | sed -e "s/^$ruby19@//" | awk '{print $1}'`}
  24. compdef _rb19 rb19
  25. function rb20 {
  26. if [ -z "$1" ]; then
  27. rvm use "$ruby"
  28. else
  29. rvm use "$ruby20@$1"
  30. fi
  31. }
  32. _rb20() {compadd `ls -1 $rvm_path/gems | grep "^$ruby20@" | sed -e "s/^$ruby20@//" | awk '{print $1}'`}
  33. compdef _rb20 rb20
  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 \
  42. -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  43. -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  44. -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  45. -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  46. }
  47. function _rvm_completion {
  48. source $rvm_path"/scripts/zsh/Completion/_rvm"
  49. }
  50. compdef _rvm_completion rvm