Created
September 15, 2019 07:50
-
-
Save tmlbl/383fa70a3c610394721319cbaa2e93c1 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
# Bash snippet for printing things in color | |
# Examples: | |
# in_color $GREEN "hello\n" | |
# in_color $RED "uh oh\n" $BOLD | |
# ok=$(in_color $GREEN OK $BOLD) | |
# echo "[ $ok ] Things are good" | |
__COLOR_RESET='\033[0m' | |
BLACK=30 | |
RED=31 | |
GREEN=32 | |
ORANGE=33 | |
BLUE=34 | |
PURPLE=35 | |
CYAN=36 | |
GRAY=37 | |
BOLD=1 | |
in_color() { | |
code=$1 | |
message=$2 | |
bold=$3 | |
if [ "$bold" = "" ]; then | |
bold="0" | |
fi | |
printf "\033[$bold;${code}m$message$__COLOR_RESET" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment