Skip to content

Instantly share code, notes, and snippets.

@cirrusUK
Created Sep 6, 2021
Embed
What would you like to do?
#!/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