From 2f67336b49a94181fdc93fadc9809a195a1fcbab Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 8 Sep 2015 02:09:37 +0200 Subject: [PATCH] Use "command" to get the bash_quote path. Check if bash_quote is available. --- zshrc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zshrc b/zshrc index 5c1a2e9..ff6fb6d 100644 --- a/zshrc +++ b/zshrc @@ -300,12 +300,16 @@ alias ccal='var=$(cal); echo "${var/$(date +%-d)/$(echo -e "\033[1;31m$(date +%- function bonjour() { MIN_TIME=$(date +%M) MODULO_MIN=$(($MIN_TIME % 2)) - if [ $MODULO_MIN -eq 0 ]; then - #echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1) - /home/${USER}/bin/bash_quote | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1) + if [ $(command -v bash_quote) ]; then + if [ $MODULO_MIN -eq 0 ]; then + #echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1) + command bash_quote | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1) + else + #echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | ponythink + command bash_quote | ponythink + fi else - #echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | ponythink - /home/${USER}/bin/bash_quote | ponythink + printf '%b' "${WHITEB}bonjour function${RESET}: One of the prerequesites is unavailable.\nFor bash_quote please see: https://git.101010.fr/dotfiles-gardouille/scripts/blob/master/bash_quote\n" fi }