timshadel
9/22/2011 - 5:04 AM

Ideas for eliminating 'bundle exec' when using rbenv

Ideas for eliminating 'bundle exec' when using rbenv

#
# ...
#

#
# Add this to ~/.rbenv/libexec/rbenv-init to load the init plugin above
#
for script in $(rbenv-plugin-scripts init); do
  source "$script"
done
#!/usr/bin/env bash
#
# Put this in ~/.rbenv/rbenv.d/init/
# Based in part on http://twistedmind.com/bundle-exec-bash-shortcut
# For a completely different take, see https://github.com/carsomyr/rbenv-bundler
#
# Slower. More correct? Choosing faster one for now.
#   echo bundled_bins=\(`rbenv exec ruby -rbundler/setup -e 'puts Bundler.rubygems.all_specs.map{|s| s.executables}.flatten.join(" ")'`\)

# Only aliases executable names of the global Ruby. Cheap way to `rbenv exec` in every version?
echo bundled_bins=\"`rbenv exec ruby -e 'puts Gem.path.inject([]) {|s,p| b = File.join(p,"bin"); (File.exists? b) ? s << Dir.entries(b).reject {|e| e =~ /\.\.?/ } : s }.flatten.join(" ")'`\"
cat <<EOS
for bin in \$bundled_bins; do
  alias \$bin="bundle exec \$bin"
done
EOS