John Otander

Open a Bundled Gem in Sublime Text

Bundler provides a wonderful command to find the location of a bundled gem. For example, if I wanted to see the location of the gem rspec, I could do the following:

$ bundle show rspec
# => /Users/johnotander/.rvm/gems/ruby-2.1.1/gems/rspec-2.14.1

However, I wanted to make it just as simple to open the gem in Sublime Text. So I wrote the following bash function:

function gs () {
  st $( bundle show $1 )

This function can be placed in your Zsh config, .zshrc.

Just like that, I can now open up the source with:

$ gs rspec



You can use the $ bundle open rspec command which uses your $EDITOR environment variable, but it will be deprecating in future versions of bundler.

Sign up for my newsletter

If you want early access to what I'm researching, writing, and building, you should subscribe to my newsletter.

No spam, ever. You can unsubscribe at any time.