Last active
August 29, 2015 14:15
-
-
Save bronzehedwick/166241a6975f063b9bca to your computer and use it in GitHub Desktop.
A little bash command line script to check Github's status with colored output!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get status from Github | |
response=$(curl --silent https://status.github.com/api/last-message.json | sed "s/{//" | sed "s/}//") | |
IFS=',' read -a messages <<< "$response" | |
#Colors | |
red="\033[0;31m" | |
green="\033[0;32m" | |
yellow="\033[0;33m" | |
# Extract the status | |
msg_status=$(echo $messages[0] | sed 's/"//g' | sed 's/status://' | sed 's/\[0\]//') | |
# Color coding based on severity | |
if [ $msg_status = 'good' ]; then | |
color=$green | |
elif [ $msg_status = 'minor' ]; then | |
color=$yellow | |
elif [ $msg_status = 'major' ]; then | |
color=$red | |
fi | |
# Output | |
echo -e "${color}${messages[1]}\033[0m" | sed 's/"//g' | sed 's/body://' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment