bundler support

This commit is contained in:
Loic Nageleisen 2012-01-13 09:18:34 +01:00
parent f246585d7e
commit 73c940356e

34
zshrc
View file

@ -48,6 +48,40 @@ HISTFILE=~/.zsh_history
autoload -Uz compinit autoload -Uz compinit
compinit compinit
# 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)
_bundler-installed() {
which bundle > /dev/null 2>&1
}
_within-bundled-project() {
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_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
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
alias $cmd=bundled_$cmd
if which _$cmd > /dev/null 2>&1; then
compdef _$cmd bundled_$cmd=$cmd
fi
done
# git completion speed boost # git completion speed boost
__git_files () { __git_files () {
_wanted files expl 'local files' _files _wanted files expl 'local files' _files