rvm.plugin.zsh 1.6 KB

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