Skip to content

Instantly share code, notes, and snippets.

@ptb
Created July 31, 2017 18:54
Show Gist options
  • Save ptb/06045623d4457cce2b7e0c62bcfb888e to your computer and use it in GitHub Desktop.
Save ptb/06045623d4457cce2b7e0c62bcfb888e to your computer and use it in GitHub Desktop.
#!/bin/sh
function ask() {
function y() { printf " \e[3;32m%s\e[0m\n" "yes"; }
function n() { printf " \e[3;31m%s\e[0m\n" "no"; }
printf "\e[1;34m%s\e[0m? \e[1;33m%s\e[0m " "${1}" "(y/n)"
for i in {1..3}; do
read -s -n 1 -t 2
case "$REPLY" in
Y|y) y; return 0; break;;
N|n) n; return 1; break;;
*) printf "\033[1;32m%s\033[0m" "."
esac
done
y; return 0
}
if ask 'Update getting started documentation'; then
echo "Whoo!"
else
echo "Nope."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment