浏览代码

Gem List Helper

Add helper function to list gems in a pretty way (only with rvm, for now). Add
missng EOF newline and a todo to the ruby plugin.
Andrew Hodges 14 年之前
父节点
当前提交
572b27b757
共有 2 个文件被更改,包括 15 次插入1 次删除
  1. 3 1
      plugins/ruby/ruby.plugin.zsh
  2. 12 0
      plugins/rvm/rvm.plugin.zsh

+ 3 - 1
plugins/ruby/ruby.plugin.zsh

@@ -1,4 +1,6 @@
+# TODO: Make this compatible with rvm.
+#       Run sudo gem on the system ruby, not the active ruby.
 alias sgem='sudo gem'
 
 # Find ruby file
-alias rfind='find . -name *.rb | xargs grep -n'
+alias rfind='find . -name *.rb | xargs grep -n'

+ 12 - 0
plugins/rvm/rvm.plugin.zsh

@@ -38,3 +38,15 @@ function rvm-update {
 function rvm-link-completion {
 	ln -s "$rvm_path/scripts/zsh/Completion/_rvm" "$ZSH/plugins/rvm/_rvm.official"
 }
+
+# TODO: Make this usable w/o rvm.
+function gems {
+	local current_ruby=`rvm-prompt i v p`
+	local current_gemset=`rvm-prompt g`
+
+	gem list $@ | sed \
+		-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
+		-Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
+		-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
+		-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
+}