Skip to content

Instantly share code, notes, and snippets.

@cirrusUK
Created September 6, 2021 20:08
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 cirrusUK/6e3d10b7a7c190780c6ce3e1fdeed868 to your computer and use it in GitHub Desktop.
Save cirrusUK/6e3d10b7a7c190780c6ce3e1fdeed868 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -eu
declare -A T=(
[red]=$'\e[0;31m' [green]=$'\e[1;32m' [orange]=$'\e[1;33m'
[lightblue]=$'\e[0;34m' [purple]=$'\e[0;35m' [cyan]=$'\e[0;36m'
[lightgray]=$'\e[0;37m' [darkgray]=$'\e[1;30em'
[lightred]=$'\e[1;31m' [lightgreen]=$'\e[0;32m'
[yellow]=$'\e[0;49;93m' [blue]=$'\e[1;34m'
[lightpurple]=$'\e[1;35m' [lightcyan]=$'\e[1;36m'
[white]=$'\e[1;37m' [nc]=$'\e[0m'
)
test_it () {
curl -s --connect-timeout 1 -o /dev/null http://google.com/
}
while true; do
if test_it; then
echo "${T[yellow]}Hey ${T[blue]}$USER ${T[yellow]}You Have ${T[green]}Internet access! 🚦 ✓${T[nc]} 💻"
sleep 1
else
echo "${T[yellow]}Hey ${T[blue]}$USER ${T[yellow]}You Have${T[lightred]}No Internet access! 🚥 ✗${T[nc]} 💻"
sleep 2.5
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment