Last active
December 21, 2015 02:29
-
-
Save hankpillow/6235637 to your computer and use it in GitHub Desktop.
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 | |
black="\033[30m" | |
gray="\033[37m" | |
light_gray="\033[97m" | |
dark_gray="\033[30m" | |
light_dark_gray="\033[90m" | |
red="\033[31m" | |
light_red="\033[91m" | |
green="\033[32m" | |
light_green="\033[92m" | |
yellow="\033[33m" | |
light_yellow="\033[93m" | |
blue="\033[34m" | |
light_blue="\033[94m" | |
magenta="\033[35m" | |
light_magenta="\033[95m" | |
cyan="\033[36m" | |
light_cyan="\033[96m" | |
function dump() { | |
echo -e "$@\033[0m" | |
} | |
function print_status() { | |
status=$(echo -e "$1" | sed 's/^ *//;') | |
if [[ "$status" =~ ^\A ]] ; | |
then | |
dump "$green$@" | |
elif [[ $status =~ ^\B ]] ; | |
then | |
dump "$gray$@" | |
elif [[ $status =~ ^\C ]] ; | |
then | |
dump "$red$@" | |
elif [[ $status =~ ^\D ]] ; | |
then | |
dump "$magenta$@" | |
elif [[ $status =~ ^\G ]] ; | |
then | |
dump "$light_yellow$@" | |
elif [[ $status =~ ^\I ]] ; | |
then | |
dump "$light_blue$@" | |
elif [[ $status =~ ^\K ]] ; | |
then | |
dump "$light_dark_gray$@" | |
elif [[ $status =~ ^\L ]] ; | |
then | |
dump "$light_red$@" | |
elif [[ $status =~ ^\M ]] ; | |
then | |
dump "$yellow$@" | |
elif [[ $status =~ ^\O ]] ; | |
then | |
dump "$light_red$@" | |
elif [[ $status =~ ^\R ]] ; | |
then | |
dump "$light_green$@" | |
elif [[ $status =~ ^\S ]] ; | |
then | |
dump "$light_green$@" | |
elif [[ $status =~ ^\T ]] ; | |
then | |
dump "$light_red$@" | |
elif [[ $status =~ ^\U ]] ; | |
then | |
dump "$light_green$@" | |
elif [[ $status =~ ^\X ]] ; | |
then | |
dump "$light_red$@" | |
elif [[ $status =~ ^\! ]] ; | |
then | |
dump "$light_magenta$@" | |
elif [[ $status =~ ^\~ ]] ; | |
then | |
dump "$red$@" | |
elif [[ $status =~ ^\+ ]] ; | |
then | |
dump "$light_blue$@" | |
elif [[ $status =~ ^\? ]] ; | |
then | |
dump "$cyan$@" | |
else | |
echo -e "$1" | |
fi | |
} | |
function check() { | |
fileStatus=$(echo -e "$1" | grep -e '^[\ A-Z!\~\+\?\~]\{2,3\}') | |
if [ -n "$fileStatus" ]; | |
then | |
print_status "$1" | |
else | |
echo -e "$1" | |
fi | |
} | |
stdin=`printf %s "$(cat)"` | |
echo -e "$stdin" | while IFS= read -r line | |
do | |
check "$line" | |
done |
the "G" status was missing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there was an issue on stdin read that was ignoring the last line. now it's fixed.