Created
August 13, 2019 20:41
-
-
Save gartz/48db52a37d2038640faf35407c59060b to your computer and use it in GitHub Desktop.
replace sudo by justdoit and give you a motivational speech when stdout/stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a keepTrying=("Yesterday you said tomorrow" | |
"Don't let your dreams be dreams" | |
"And you're not going to stop there" | |
"No, what are you waiting for?") | |
declare -a youDidIt=("You should get to the point where anyone else would quit" | |
"Make your dreams come true" | |
"Nothing is impossible" | |
"And you're not going to stop there" | |
"If you're tired of starting over") | |
justdoit() | |
{ | |
sudo "$@" | |
if [ $? -eq 0 ]; then | |
NUM=${#youDidIt[@]} | |
CHOICE=$(expr "$(echo $RANDOM%${NUM} | bc) + 1") | |
R=$RANDOM | |
echo "${youDidIt[${CHOICE}]}" | |
else | |
NUM=${#keepTrying[@]} | |
CHOICE=$(expr "$(echo $RANDOM%${NUM} | bc) + 1") | |
R=$RANDOM | |
echo "${keepTrying[${CHOICE}]}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment