Skip to content

Instantly share code, notes, and snippets.

@bronzehedwick
Last active August 29, 2015 14:15
Show Gist options
  • Save bronzehedwick/166241a6975f063b9bca to your computer and use it in GitHub Desktop.
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!
#!/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