Skip to content

Instantly share code, notes, and snippets.

@etrepat
Created December 12, 2011 11:03

Revisions

  1. etrepat revised this gist Dec 12, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install.md
    Original file line number Diff line number Diff line change
    @@ -5,5 +5,5 @@

    F.ex:

    $ curl -L https://github.com/gma/bundler-exec/raw/master/bundler-exec.sh > ~/.bundler-exec.sh
    $ curl -L https://gist.github.com/raw/1466610/1c43c0ab209eac10896844b137dc127ce439fb5a/bundler-exec.sh > ~/.bundler-exec.sh
    $ echo "[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh" >> ~/.bashrc
  2. etrepat revised this gist Dec 12, 2011. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions bundler-exec.sh
    Original file line number Diff line number Diff line change
    @@ -37,8 +37,6 @@ bundler-installed()
    which bundle > /dev/null 2>&1
    }



    within-bundled-project()
    {
    local dir="$(pwd)"
  3. etrepat created this gist Dec 12, 2011.
    65 changes: 65 additions & 0 deletions bundler-exec.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    #!/bin/bash

    BUNDLED_COMMANDS="${BUNDLED_COMMANDS:-
    cap
    capify
    cucumber
    foreman
    guard
    haml
    heroku
    html2haml
    rackup
    rails
    rake
    rake2thor
    rspec
    ruby
    sass
    sass-convert
    serve
    shotgun
    spec
    spork
    thin
    thor
    tilt
    tt
    turn
    unicorn
    unicorn_rails
    }"

    ## Functions

    bundler-installed()
    {
    which bundle > /dev/null 2>&1
    }



    within-bundled-project()
    {
    local dir="$(pwd)"
    while [ "$(dirname $dir)" != "/" ]; do
    [ -f "$dir/Gemfile" ] && return
    dir="$(dirname $dir)"
    done
    false
    }

    run-with-bundler()
    {
    if bundler-installed && within-bundled-project; then
    bundle exec $@
    else
    $@
    fi
    }

    ## Main program

    for CMD in $BUNDLED_COMMANDS; do
    alias $CMD="run-with-bundler $CMD"
    done
    9 changes: 9 additions & 0 deletions install.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    ## Install

    * Copy bundler-exec.sh to ~/.bundler-exec.sh.
    * Source it from your ~/.bashrc file.

    F.ex:

    $ curl -L https://github.com/gma/bundler-exec/raw/master/bundler-exec.sh > ~/.bundler-exec.sh
    $ echo "[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh" >> ~/.bashrc