rvm.plugin.zsh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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-p334'
  5. local ruby19='ruby-1.9.3-p194'
  6. function rb18 {
  7. if [ -z "$1" ]; then
  8. rvm use "$ruby18"
  9. else
  10. rvm use "$ruby18@$1"
  11. fi
  12. }
  13. _rb18() {compadd `ls -1 $rvm_path/gems | grep "^$ruby18@" | sed -e "s/^$ruby18@//" | awk '{print $1}'`}
  14. compdef _rb18 rb18
  15. function rb19 {
  16. if [ -z "$1" ]; then
  17. rvm use "$ruby19"
  18. else
  19. rvm use "$ruby19@$1"
  20. fi
  21. }
  22. _rb19() {compadd `ls -1 $rvm_path/gems | grep "^$ruby19@" | sed -e "s/^$ruby19@//" | awk '{print $1}'`}
  23. compdef _rb19 rb19
  24. function rvm-update {
  25. rvm get head
  26. rvm reload # TODO: Reload rvm completion?
  27. }
  28. # TODO: Make this usable w/o rvm.
  29. function gems {
  30. local current_ruby=`rvm-prompt i v p`
  31. local current_gemset=`rvm-prompt g`
  32. gem list $@ | sed \
  33. -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  34. -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  35. -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  36. -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  37. }
  38. function _rvm_completion {
  39. source $rvm_path"/scripts/zsh/Completion/_rvm"
  40. }
  41. compdef _rvm_completion rvm