Stop Typing `bundle exec`

Bundler is awesome. It’s the one true way to ensure proper dependency management for Ruby projects. Yet, it can be painful to type bundle exec before shell commands.

Sure, binstubs exist, but I don’t like them. Typing bin/mygem still doesn’t satisfy me and prepending ./bin to my $PATH is too transparent. I prefer explicitly calling bundle exec only when I want.

That’s why I just use a good ol’ shell alias:

alias be="bundle exec "

* Note the trailing space to trigger alias chaining.

Then, I can call project-specific binaries by prepending be instead of bundle exec:

# before
bundle exec rails server

# after
be rails server

This is explicit, obvious, and short enough for my taste.

You might find other useful aliases in my dotfiles. Happy aliasing!