bundler and go suport for bash too

This commit is contained in:
Loic Nageleisen 2013-12-19 10:24:26 +01:00
parent 85d27c709e
commit 6f4df09b76
4 changed files with 25 additions and 15 deletions

38
shell/bundler Normal file
View file

@ -0,0 +1,38 @@
# bundler
bundled_commands=(annotate cap capify cucumber foreman guard heroku nanoc rackup rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails irb rails pry)
_bundler-installed() {
which bundle > /dev/null 2>&1
}
_within-bundled-project() {
local check_dir=$PWD
local next_check_dir=${check_dir%/*}
while [ "$next_check_dir" != "" ]; do
[[ -f "$check_dir/Gemfile" ]] && return
check_dir="$next_check_dir"
next_check_dir=${check_dir%/*}
done
false
}
_run-with-bundler() {
if _bundler-installed && _within-bundled-project; then
bundle exec $@
else
$@
fi
}
for cmd in ${bundled_commands[@]}; do
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@; }"
alias $cmd=bundled_$cmd
if [[ -n $ZSH_VERSION ]]; then
if declare -f _$cmd > /dev/null 2>&1; then
compdef _$cmd bundled_$cmd=$cmd
fi
fi
done
# vim: ft=zsh