Skip to content

Instantly share code, notes, and snippets.

@timshadel
Created September 22, 2011 05:04
Show Gist options
  • Save timshadel/1234077 to your computer and use it in GitHub Desktop.
Save timshadel/1234077 to your computer and use it in GitHub Desktop.
Ideas for eliminating 'bundle exec' when using rbenv
#!/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
#
# ...
#
#
# Add this to ~/.rbenv/libexec/rbenv-init to load the init plugin above
#
for script in $(rbenv-plugin-scripts init); do
source "$script"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment