Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Created September 26, 2014 19:58
Show Gist options
  • Save wesleyit/a8144066ab577f030bd6 to your computer and use it in GitHub Desktop.
Save wesleyit/a8144066ab577f030bd6 to your computer and use it in GitHub Desktop.
This script will export functions used to print colorful messages in shell scripts or terminal commands.
#!/bin/bash
# ##########################################################
# shell_colors.sh
# This script will export functions used to print colorful
# messages in shell scripts or terminal commands.
# Wesley Rodrigues da Silva <wesley.it at gmail.com>
# LICENCE CREATIVE COMMONS BY - 2014
# http://creativecommons.org/licenses/by/2.0/legalcode
# ##########################################################
# Colors definitions (we will start with 4 colors)
RESET=0
TXT_RED=31
TXT_BLUE=34
TXT_GREEN=32
TXT_YELLOW=33
ESCAPE="\033["
function RED() {
COLOR_BACKGROUND=$RESET
COLOR_TEXT=$TXT_RED
echo -ne "${ESCAPE}${RESET}m"
echo -ne "${ESCAPE}${COLOR_BACKGROUND};${COLOR_TEXT}m${@}"
echo -ne "${ESCAPE}${RESET}m"
}
function GREEN() {
COLOR_BACKGROUND=$RESET
COLOR_TEXT=$TXT_GREEN
echo -ne "${ESCAPE}${RESET}m"
echo -ne "${ESCAPE}${COLOR_BACKGROUND};${COLOR_TEXT}m${@}"
echo -ne "${ESCAPE}${RESET}m"
}
function BLUE() {
COLOR_BACKGROUND=$RESET
COLOR_TEXT=$TXT_BLUE
echo -ne "${ESCAPE}${RESET}m"
echo -ne "${ESCAPE}${COLOR_BACKGROUND};${COLOR_TEXT}m${@}"
echo -ne "${ESCAPE}${RESET}m"
}
function YELLOW() {
COLOR_BACKGROUND=$RESET
COLOR_TEXT=$TXT_YELLOW
echo -ne "${ESCAPE}${RESET}m"
echo -ne "${ESCAPE}${COLOR_BACKGROUND};${COLOR_TEXT}m${@}"
echo -ne "${ESCAPE}${RESET}m"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment