From: Alexander Barton Date: Mon, 8 Jun 2015 12:59:24 +0000 (+0200) Subject: Change plugins to not do anything if tool isn't available X-Git-Url: https://arthur.ath.cx/gitweb/?a=commitdiff_plain;h=9ea48355673a75f1d63320be20a231837a816781;p=OhMyZshExtensions.git Change plugins to not do anything if tool isn't available Don't even echo error messages, simply skip the plugin to do anything when the respective tool(s) isn't available on the system. --- diff --git a/plugins/5_dev_env/5_dev_env.plugin.zsh b/plugins/5_dev_env/5_dev_env.plugin.zsh index 2977ff8..9e4cd26 100644 --- a/plugins/5_dev_env/5_dev_env.plugin.zsh +++ b/plugins/5_dev_env/5_dev_env.plugin.zsh @@ -15,10 +15,14 @@ done unset ssh_wrapper # pip -export PIP_REQUIRE_VIRTUALENV="true" +if (( $+commands[pip] )); then + export PIP_REQUIRE_VIRTUALENV="true" +fi # virtualenv[wrapper] -export WORKON_HOME="$XDG_CACHE_HOME/virtualenvs" -[ -d "$LOCAL_HOME/Develop" ] \ - && export PROJECT_HOME="$LOCAL_HOME/Develop" \ - || export PROJECT_HOME="$HOME/Develop" +if (( $+commands[virtualenv] )); then + export WORKON_HOME="$XDG_CACHE_HOME/virtualenvs" + [ -d "$LOCAL_HOME/Develop" ] \ + && export PROJECT_HOME="$LOCAL_HOME/Develop" \ + || export PROJECT_HOME="$HOME/Develop" +fi diff --git a/plugins/boot2docker/boot2docker.plugin.zsh b/plugins/boot2docker/boot2docker.plugin.zsh index 9813acd..8a63173 100644 --- a/plugins/boot2docker/boot2docker.plugin.zsh +++ b/plugins/boot2docker/boot2docker.plugin.zsh @@ -1,8 +1,10 @@ # boot2docker.plugin.zsh -boot2docker status | fgrep "running" >/dev/null -if [ $? -eq 0 ]; then - # boot2docker VM is running - eval `boot2docker shellinit 2>/dev/null` - DOCKER_HOST_IPA=${(z)${(s.:.)DOCKER_HOST#tcp://}[1]} +if (( $+commands[boot2docker] )); then + boot2docker status | fgrep "running" >/dev/null + if [ $? -eq 0 ]; then + # boot2docker VM is running + eval `boot2docker shellinit 2>/dev/null` + DOCKER_HOST_IPA=${(z)${(s.:.)DOCKER_HOST#tcp://}[1]} + fi fi diff --git a/plugins/keychain/keychain.plugin.zsh b/plugins/keychain/keychain.plugin.zsh index c1c6fbb..e01f9ae 100644 --- a/plugins/keychain/keychain.plugin.zsh +++ b/plugins/keychain/keychain.plugin.zsh @@ -1,3 +1,5 @@ # keychain.plugin.zsh -eval $(keychain --agents ssh --eval --quick --quiet) +if (( $+commands[keychain] )); then + eval $(keychain --agents ssh --eval --quick --quiet) +fi diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 4042544..754d342 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -1,3 +1,5 @@ # thefuck.plugin.zsh -alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' +if (( $+commands[thefuck] )); then + alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' +fi