Skip to content

Instantly share code, notes, and snippets.

@rpearce
Created August 22, 2023 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpearce/9f5d364d47209081ce2b6521e2e91183 to your computer and use it in GitHub Desktop.
Save rpearce/9f5d364d47209081ce2b6521e2e91183 to your computer and use it in GitHub Desktop.
Gift for my friend, Len
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
set -eou pipefail
# ==============================================================================
function clearscreen {
printf '\033c'
}
# ==============================================================================
function print_welcome {
cat <<EOF
┌─────────────────────────┐
│ │
│ Welcome to │
│ │
│ Len's │
│ │
│ Silly Challenge! │
│ │
└─────────────────────────┘
EOF
}
function print_overview {
cat <<EOF
┌───────────────────────────┐
│ │
│ You will be given │
│ │
│ THREE │
│ │
│ (obscure) │
│ │
│ questions about │
│ │
│ ¡GOLF! │
│ │
│ that you must answer │
│ │
│ to unlock... │
│ │
└───────────────────────────┘
EOF
}
function print_gift_preview {
echo " ___ ___ ___ ___ ";
echo " ___ /__/\ / /\ / /\ ___ / /\ ___ ";
echo " / /\ \ \:\ / /:/_ / /:/_ / /\ / /:/_ / /\ ";
echo " / /:/ \__\:\ / /:/ /\ / /:/ /\ / /:/ / /:/ /\ / /:/ ";
echo " / /:/ ___ / /::\ / /:/ /:/_ / /:/_/::\ /__/::\ / /:/ /:/ / /:/ ";
echo " / /::\ /__/\ /:/\:\ /__/:/ /:/ /\ /__/:/__\/\:\ \__\/\:\__ /__/:/ /:/ / /::\ ";
echo " /__/:/\:\ \ \:\/:/__\/ \ \:\/:/ /:/ \ \:\ /~~/:/ \ \:\/\ \ \:\/:/ /__/:/\:\ ";
echo " \__\/ \:\ \ \::/ \ \::/ /:/ \ \:\ /:/ \__\::/ \ \::/ \__\/ \:\ ";
echo " \ \:\ \ \:\ \ \:\/:/ \ \:\/:/ /__/:/ \ \:\ \ \:\\";
echo " \__\/ \ \:\ \ \::/ \ \::/ \__\/ \ \:\ \__\/";
echo " \__\/ \__\/ \__\/ \__\/ ";
}
# ==============================================================================
function run_q1 {
local msg="${1-}"
clearscreen
print_q1
if [ -n "$msg" ]; then
echo "$msg"
fi
read -erp "> " answer
if [ "$answer" = "Condor" ] || [ "$answer" = "condor" ]; then
echo ""
print_q1_success
else
run_q1 "(Please try again)"
fi
}
function print_q1 {
cat <<EOF
┌──────────────────────────────────────┐
│ │
│ Q1: What do you call a hole in 1 │
│ on a par 5? (One word) │
│ │
└──────────────────────────────────────┘
EOF
}
function print_q1_success {
cat <<EOF
┌────────────────┐
│ │
│ Great Job! │
│ │
└────────────────┘
EOF
read -erp "(Press return to continue)" _
}
# ==============================================================================
function run_q2 {
local msg="${1-}"
clearscreen
print_q2
if [ -n "$msg" ]; then
echo "$msg"
fi
read -erp "> " answer
if [ "$answer" = "1457" ]; then
echo ""
print_q2_success
else
run_q2 "(Please try again)"
fi
}
function print_q2 {
cat <<EOF
┌───────────────────────────────────────────────────┐
│ │
│ Q2: When was golf first mentioned in history? │
│ │
└───────────────────────────────────────────────────┘
EOF
}
function print_q2_success {
cat <<EOF
┌────────────────────┐
│ │
│ Wow! You rock! │
│ │
└────────────────────┘
EOF
read -erp "(Press return to continue)" _
}
# ==============================================================================
function run_q3 {
local msg="${1-}"
clearscreen
print_q3
if [ -n "$msg" ]; then
echo "$msg"
fi
read -erp "> " answer
if [ "$answer" = "Feathers" ] || [ "$answer" = "feathers" ]; then
echo ""
print_q3_success
else
run_q3 "(Please try again)"
fi
}
function print_q3 {
cat <<EOF
┌────────────────────────────────────────────┐
│ │
│ Q3: Golf balls were originally made of │
│ leather and what other substance? │
│ │
└────────────────────────────────────────────┘
EOF
}
function print_q3_success {
cat <<EOF
┌──────────────────────┐
│ │
│ Amazing! How did │
│ │
│ you know that?!? │
│ │
└──────────────────────┘
EOF
read -erp "(Press return to continue)" _
}
# ==============================================================================
function print_gift {
cat <<EOF
┌────────────────────────────────────────────────────────┐
│ │
│ You have earned \$75 to spend how you like, but I │
│ │
│ recommend ordering your favorite food and relaxing │
│ │
│ with your girls. │
│ │
│ │
│ │
│ Message me "I made par" to let me know to Venmo! │
│ │
│ │
│ │
│ Hope you're having a great day, │
│ │
│ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ████████╗ │
│ ██╔══██╗██╔═══██╗██╔══██╗██╔════╝██╔══██╗╚══██╔══╝ │
│ ██████╔╝██║ ██║██████╔╝█████╗ ██████╔╝ ██║ │
│ ██╔══██╗██║ ██║██╔══██╗██╔══╝ ██╔══██╗ ██║ │
│ ██║ ██║╚██████╔╝██████╔╝███████╗██║ ██║ ██║ │
│ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ │
│ │
│ │
└────────────────────────────────────────────────────────┘
EOF
}
# ==============================================================================
function main {
clearscreen
print_welcome
read -erp "(Press return to continue)" _
clearscreen
print_overview
read -erp "(Press return to continue)" _
print_gift_preview
read -erp "(Press return to be tested)" _
run_q1
run_q2
run_q3
clearscreen
print_gift
read -erp "(Press return to go to a Ted Lasso GIF)" _
open https://gifdb.com/images/high/ted-lasso-high-five-01z3yguvu4vlrthk.gif
}
main
@rpearce
Copy link
Author

rpearce commented Aug 22, 2023

Here's how to run this!

  1. Copy the commands below to your clipboard
  2. Open your Terminal.app application on your Mac and make it full screen (hold command & option and click the green button in the top left)
  3. Paste in the commands, press return, and enjoy!
curl -sSL https://gist.githubusercontent.com/rpearce/9f5d364d47209081ce2b6521e2e91183/raw -o ./gift-len && \
  chmod +x ./gift-len && \
  ./gift-len

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment