prezto/plugins/bundler/bundler.plugin.zsh

57 lines
908 B
Bash
Raw Normal View History

2011-08-30 23:16:15 -04:00
# Aliases
2011-02-15 11:27:25 -08:00
alias be="bundle exec"
alias bi="bundle install"
alias bl="bundle list"
2011-08-30 23:16:15 -04:00
alias bo="bundle open"
alias bp="bundle package"
2011-08-30 23:16:15 -04:00
alias bu="bundle update"
# The following is based on https://github.com/gma/bundler-exec
2011-08-30 23:16:15 -04:00
bundled_commands=(
cap
capify
cucumber
guard
heroku
rackup
rails
rake
rspec
ruby
shotgun
spec
spork
thin
unicorn
unicorn_rails
)
2011-08-30 23:16:15 -04:00
# Functions
function _bundler-installed() {
which bundle > /dev/null 2>&1
}
2011-08-30 23:16:15 -04:00
function _bundler-within-bundled-project() {
local check_dir=$PWD
2011-08-30 23:16:15 -04:00
while [[ "$(dirname $check_dir)" != "/" ]]; do
[[ -f "$check_dir/Gemfile" ]] && return
check_dir="$(dirname $check_dir)"
done
false
}
2011-08-30 23:16:15 -04:00
function _bundler-run() {
if _bundler-installed && __bundler-within-bundled-project; then
bundle exec $@
else
$@
fi
}
for cmd in $bundled_commands; do
2011-08-30 23:16:15 -04:00
alias $cmd="_bundler-run $cmd"
done
2011-08-30 23:16:15 -04:00
unset bundled_commands