summaryrefslogtreecommitdiff
path: root/plugins/bundler
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/bundler')
-rw-r--r--plugins/bundler/bundler.plugin.zsh39
1 files changed, 27 insertions, 12 deletions
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index c01241409..e390f8620 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -1,13 +1,13 @@
alias be="bundle exec"
-alias bi="bundle install"
alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
+
# The following is based on https://github.com/gma/bundler-exec
-bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor thin thor unicorn unicorn_rails puma)
+bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma)
## Functions
@@ -32,13 +32,28 @@ _run-with-bundler() {
fi
}
-## Main program
-for cmd in $bundled_commands; do
- eval "function unbundled_$cmd () { $cmd \$@ }"
- 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
+if _bundler-installed; then
+ bundler_version=`bundle version | cut -d' ' -f3`
+ if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
+ if [[ "$(uname)" == 'Darwin' ]]
+ then
+ local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
+ else
+ local cores_num="$(nproc)"
+ fi
+ eval "alias bi='bundle install --jobs=$cores_num'"
+ else
+ alias bi='bundle install'
+ fi
+
+ ## Main program
+ for cmd in $bundled_commands; do
+ eval "function unbundled_$cmd () { $cmd \$@ }"
+ 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
+fi