Skip to content

Instantly share code, notes, and snippets.

@samleb
Last active December 17, 2015 23:39
Show Gist options
  • Select an option

  • Save samleb/5690666 to your computer and use it in GitHub Desktop.

Select an option

Save samleb/5690666 to your computer and use it in GitHub Desktop.
Shell snippets to deal with rubygems (only tested on zsh)
function gems-dir () {
echo `ruby -rrubygems -e "puts Gem.dir"`/gems
}
function gems {
cd `gems-dir`
pwd
}
function gem-home {
open `gem spec -r $@ | grep homepage: | sed "s/^homepage: //"`
}
function edit-gem {
local dir
dir=`gems-dir`/`ruby -rrubygems -e "puts Gem::Specification.find_by_name('$@').full_name" 2> /dev/null`
[ $? -eq 0 ] && eval $EDITOR $dir
}
alias eg="edit-gem"
function edit-bundle {
local bundle
bundle="$(bundle show $1)"
[ $? -eq 0 ] && eval $EDITOR $bundle || echo $bundle
}
alias eb="edit-bundle"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment