Skip to content

Instantly share code, notes, and snippets.

@gartz
Created August 13, 2019 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gartz/48db52a37d2038640faf35407c59060b to your computer and use it in GitHub Desktop.
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
#!/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