Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 511 Bytes

style_bash_script_text.md

File metadata and controls

27 lines (22 loc) · 511 Bytes

Style bash script text

print_style() {
    if [ "$2" == "info" ]; then
        COLOR="96m"
    elif [ "$2" == "success" ]; then
        COLOR="92m"
    elif [ "$2" == "warning" ]; then
        COLOR="93m"
    elif [ "$2" == "danger" ]; then
        COLOR="91m"
    elif [ "$2" == "error" ]; then
        COLOR="41m"
    else #default color
        COLOR="0m"
    fi


    STARTCOLOR="\e[$COLOR"
    ENDCOLOR="\e[0m"

    printf "$STARTCOLOR%b$ENDCOLOR" "$1"
}

print_style "Some error" "danger";