rvm.plugin.zsh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. fpath=($ZSH/plugins/rvm $fpath)
  2. autoload -U compinit
  3. compinit -i
  4. alias rubies='rvm list rubies'
  5. alias gemsets='rvm gemset list'
  6. local ruby18='ruby-1.8.7-p334'
  7. local ruby19='ruby-1.9.2-p180'
  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 rvm-update {
  27. rvm get head
  28. rvm reload # TODO: Reload rvm completion?
  29. }
  30. function rvm-link-completion {
  31. ln -s "$rvm_path/scripts/zsh/Completion/_rvm" "$ZSH/plugins/rvm/_rvm.official"
  32. }
  33. # TODO: Make this usable w/o rvm.
  34. function gems {
  35. local current_ruby=`rvm-prompt i v p`
  36. local current_gemset=`rvm-prompt g`
  37. gem list $@ | sed \
  38. -Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
  39. -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
  40. -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
  41. -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
  42. }