Skip to content

Instantly share code, notes, and snippets.

@ikasty
Created May 10, 2019 06:40
Show Gist options
  • Save ikasty/12fdca7f4af138e1312e3ae051c72c20 to your computer and use it in GitHub Desktop.
Save ikasty/12fdca7f4af138e1312e3ae051c72c20 to your computer and use it in GitHub Desktop.
Commit lotto
target=$(git rev-parse --short=7 HEAD 2>&1)
if [ "$?" -eq "0" ]; then
echo -n "Roll commit lotto... "
count=$(sed 's/^ *\([0-9]\+\).*$/\1/' <<< `echo "$target" | fold -w1 | sort | uniq -c | sort | tail -n1`)
if [[ "$target" =~ ^[0-9]+$ ]]; then
echo "You won numeric lotto! (3.725%)"
elif [[ "$target" =~ ^[a-f]+$ ]]; then
echo "You won alphabet lotto! (0.104%)"
elif [ "$count" -eq "4" ]; then
echo "You won 4 same lotto! (0.00586%)"
elif [ "$count" -eq "5" ]; then
echo "You won 5 same lotto! (0.000320%)"
elif [ "$count" -eq "6" ]; then
echo "You won 6 same lotto! (0.00000668%)"
elif [ "$count" -eq "7" ]; then
echo "You won all same lotto! (0.0000000596%)"
else
echo "failed. Maybe next time!"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment