a4f4ed037ad37ff91594b442c71bde191a547096
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #2243 from sabarishcrri/bundle_plugin_nobundle_fix
bundle plugin throwing error when bundle is not in path while initializing
Diff
1diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
2index 2e657e5a820b83463b4af463d76f035b6404c58f..e390f8620bb1252e7b0f14072bf90c7d92fef36e 100644
3--- a/plugins/bundler/bundler.plugin.zsh
4+++ b/plugins/bundler/bundler.plugin.zsh
5@@ -4,18 +4,6 @@ alias bp="bundle package"
6 alias bo="bundle open"
7 alias bu="bundle update"
8
9-bundler_version=`bundle version | cut -d' ' -f3`
10-if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
11- if [[ "$(uname)" == 'Darwin' ]]
12- then
13- local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
14- else
15- local cores_num="$(nproc)"
16- fi
17- eval "alias bi='bundle install --jobs=$cores_num'"
18-else
19- alias bi='bundle install'
20-fi
21
22 # The following is based on https://github.com/gma/bundler-exec
23
24@@ -44,14 +32,28 @@ _run-with-bundler() {
25 fi
26 }
27
28-## Main program
29-for cmd in $bundled_commands; do
30- eval "function unbundled_$cmd () { $cmd \$@ }"
31- eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
32- alias $cmd=bundled_$cmd
33-
34- if which _$cmd > /dev/null 2>&1; then
35- compdef _$cmd bundled_$cmd=$cmd
36- fi
37-done
38-
39+if _bundler-installed; then
40+ bundler_version=`bundle version | cut -d' ' -f3`
41+ if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
42+ if [[ "$(uname)" == 'Darwin' ]]
43+ then
44+ local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
45+ else
46+ local cores_num="$(nproc)"
47+ fi
48+ eval "alias bi='bundle install --jobs=$cores_num'"
49+ else
50+ alias bi='bundle install'
51+ fi
52+
53+ ## Main program
54+ for cmd in $bundled_commands; do
55+ eval "function unbundled_$cmd () { $cmd \$@ }"
56+ eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
57+ alias $cmd=bundled_$cmd
58+
59+ if which _$cmd > /dev/null 2>&1; then
60+ compdef _$cmd bundled_$cmd=$cmd
61+ fi
62+ done
63+fi