Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created August 17, 2009 06:09
Show Gist options
  • Save davidlee/168941 to your computer and use it in GitHub Desktop.
Save davidlee/168941 to your computer and use it in GitHub Desktop.
#
# gem tools (ZSH)
#
# this is a guess. salt to taste.
export GEMPATH=`ruby -e 'require "rubygems"; puts Gem.path.reject{|p| p =~ /\.gem/ }.first'`/gems
# completion fuction for compdef: just lists the gems folders
_gems() { compadd `cd $GEMPATH; echo *` }
_ghems() { compadd `cd $GEMPATH; echo *-[a-z]* | egrep '' ` }
compdef _gems gemcd ; gemcd() { cd $GEMPATH/$1 }
compdef _gems gemedit ; gemedit() { $VISUAL $GEMPATH/$1 }
compdef _gems gemgrep ; gemgrep() { grep -r $1 $GEMPATH/$2 }
compdef _gems gemgrin ; gemgrin() { grin $1 $GEMPATH/$2 }
compdef _ghems ghcd ; ghcd() { cd $GEMPATH/$1 }
compdef _ghems ghedit ; ghedit() { $VISUAL $GEMPATH/$1 }
compdef _gems ghgrep ; ghgrep() { grep -r $1 $GEMPATH/$2 }
compdef _gems ghgrin ; ghgrin() { grin $1 $GEMPATH/$2 }
# alias g="echo $GEMPATH"
alias gme="gemedit $1"
alias gmc="gemcd $1"
alias gmg="gemgrin $1 $2"
alias ghe="ghedit $1"
alias ghc="ghcd $1"
alias ghg="ghgrin $1 $2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment