rvm.plugin.zsh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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-p371'
  5. local ruby19='ruby-1.9.3-p392'
  6. local ruby20='ruby-2.0.0-p0'
  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. rvm reload # TODO: Reload rvm completion?
  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 \
  43. -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  44. -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  45. -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  46. -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  47. }
  48. function _rvm_completion {
  49. source $rvm_path"/scripts/zsh/Completion/_rvm"
  50. }
  51. compdef _rvm_completion rvm