Skip to content

Instantly share code, notes, and snippets.

@aaronfeng
Last active December 31, 2015 19:09

Revisions

  1. aaronfeng revised this gist Dec 18, 2013. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions bundle_ruby
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,6 @@ function ruby_wrapper() {
    unalias ruby
    CURRENT_RUBY=$(which ruby)

    echo $CURRENT_RUBY

    if [ -e "$(pwd)/Gemfile.lock" ]
    then
    bundle exec $CURRENT_RUBY "$@"
  2. aaronfeng created this gist Dec 18, 2013.
    26 changes: 26 additions & 0 deletions bundle_ruby
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/bin/bash

    # remember original ruby location
    export CURRENT_RUBY=$(which ruby)

    alias ruby="ruby_wrapper"

    # call bundle exec if there's a Gemfile.lock
    function ruby_wrapper() {
    # unalias it to get the real ruby version
    # this is require if ruby was switch via rvm or rbenv
    unalias ruby
    CURRENT_RUBY=$(which ruby)

    echo $CURRENT_RUBY

    if [ -e "$(pwd)/Gemfile.lock" ]
    then
    bundle exec $CURRENT_RUBY "$@"
    else
    $CURRENT_RUBY "$@"
    fi

    # set the alias back for next interception
    alias ruby="ruby_wrapper"
    }