summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSabarish Kumar R <skumar@crri.co.in>2013-11-12 12:31:13 +0530
committerSabarish Kumar R <skumar@crri.co.in>2013-11-12 12:31:13 +0530
commit27f9747143e421e6908e9c2d0eb6247df4a3af8c (patch)
treeb1ae0ed86dd90cb1319cd0a01b74cfe7f8f8eb7c
parente30a1243dc89814e9f31e4b4cc284d948ecbfbd8 (diff)
downloadzsh-27f9747143e421e6908e9c2d0eb6247df4a3af8c.tar.gz
zsh-27f9747143e421e6908e9c2d0eb6247df4a3af8c.tar.bz2
zsh-27f9747143e421e6908e9c2d0eb6247df4a3af8c.zip
bundle plugin throwing error when bundle is not in path while initializing
-rw-r--r--plugins/bundler/bundler.plugin.zsh48
1 files changed, 25 insertions, 23 deletions
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 2e657e5a8..e390f8620 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -4,18 +4,6 @@ alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
-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
# The following is based on https://github.com/gma/bundler-exec
@@ -44,14 +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