rvm.plugin.zsh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. fpath=($rvm_path/scripts/zsh/Completion $fpath)
  2. alias rubies='rvm list rubies'
  3. alias rvms='rvm gemset'
  4. alias gemsets='rvms list'
  5. local ruby18='ruby-1.8.7'
  6. local ruby19='ruby-1.9.3'
  7. local ruby20='ruby-2.0.0'
  8. local ruby21='ruby-2.1.2'
  9. function rb18 {
  10. if [ -z "$1" ]; then
  11. rvm use "$ruby18"
  12. else
  13. rvm use "$ruby18@$1"
  14. fi
  15. }
  16. _rb18() {compadd `ls -1 $rvm_path/gems | grep "^$ruby18@" | sed -e "s/^$ruby18@//" | awk '{print $1}'`}
  17. compdef _rb18 rb18
  18. function rb19 {
  19. if [ -z "$1" ]; then
  20. rvm use "$ruby19"
  21. else
  22. rvm use "$ruby19@$1"
  23. fi
  24. }
  25. _rb19() {compadd `ls -1 $rvm_path/gems | grep "^$ruby19@" | sed -e "s/^$ruby19@//" | awk '{print $1}'`}
  26. compdef _rb19 rb19
  27. function rb20 {
  28. if [ -z "$1" ]; then
  29. rvm use "$ruby20"
  30. else
  31. rvm use "$ruby20@$1"
  32. fi
  33. }
  34. _rb20() {compadd `ls -1 $rvm_path/gems | grep "^$ruby20@" | sed -e "s/^$ruby20@//" | awk '{print $1}'`}
  35. compdef _rb20 rb20
  36. function rb21 {
  37. if [ -z "$1" ]; then
  38. rvm use "$ruby21"
  39. else
  40. rvm use "$ruby21@$1"
  41. fi
  42. }
  43. _rb21() {compadd `ls -1 $rvm_path/gems | grep "^$ruby21@" | sed -e "s/^$ruby21@//" | awk '{print $1}'`}
  44. compdef _rb21 rb21
  45. function rvm-update {
  46. rvm get head
  47. }
  48. # TODO: Make this usable w/o rvm.
  49. function gems {
  50. local current_ruby=`rvm-prompt i v p`
  51. local current_gemset=`rvm-prompt g`
  52. gem list $@ | sed -E \
  53. -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  54. -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  55. -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  56. -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  57. }
  58. function _rvm_completion {
  59. source $rvm_path"/scripts/zsh/Completion/_rvm"
  60. }
  61. compdef _rvm_completion rvm