When working on a Rails app, you sometimes need to dig into a gem. Maybe you’ve got a failing test that really seriously shouldn’t be failing or maybe you would just like to know what’s going on behind the scenes. In either case wouldn’t it be nice to open up any given gem right there, with a simple command rather than diving into that gem’s full local path?
Boom. The gem’s source directory will open in your editor. No more copying and pasting long paths or trying to navigate through 30 subdirectories to the gem you want.
configure the $EDITOR environment variable
bundle open to work you must set your
$EDITOR environment variable. To do this (and have your shell remember the change when you restart), simply add
.bash_profile (assuming you’re using OS X), substituting vim for your editor of choice (but hopefully it’s vim).
so that your shell re-builds the script and applies the changes to your currently running session.
You can check that it worked by running
and you should see the editor you’ve set.