Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
replace sudo by justdoit and give you a motivational speech when stdout/stderr
#!/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
You can’t perform that action at this time.