Colors
This commit is contained in:
parent
18b8f5ee27
commit
b78b368913
37
colors.sh
37
colors.sh
@ -5,26 +5,39 @@
|
|||||||
# Author: Roman Ožana <roman@ozana.cz>
|
# Author: Roman Ožana <roman@ozana.cz>
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
|
||||||
# Define Colors
|
# Basic colors
|
||||||
|
export BLACK='\033[0;30m'
|
||||||
export GRAY='\033[0;90m'
|
export GRAY='\033[0;90m'
|
||||||
export LIGHT_GRAY='\033[0;90m'
|
|
||||||
export YELLOW='\033[0;33m'
|
|
||||||
export LIGHT_YELLOW='\033[0;93m'
|
|
||||||
export GREEN='\033[0;32m'
|
|
||||||
export LIGHT_GREEN='\033[0;92m'
|
|
||||||
export RED='\033[0;31m'
|
export RED='\033[0;31m'
|
||||||
export LIGHT_RED='\033[0;91m'
|
export GREEN='\033[0;32m'
|
||||||
export BLUE='\033[0;34m'
|
export BLUE='\033[0;34m'
|
||||||
export LIGHT_BLUE='\033[0;94m'
|
export YELLOW='\033[0;33m'
|
||||||
export MAGENTA='\033[0;35m'
|
export MAGENTA='\033[0;35m'
|
||||||
export LIGHT_MAGENTA='\033[0;95m'
|
|
||||||
export CYAN='\033[0;36m'
|
export CYAN='\033[0;36m'
|
||||||
export WHITE='\033[0;37m'
|
export WHITE='\033[0;37m'
|
||||||
export BLACK='\033[0;30m'
|
export NC='\033[0m' # reset color
|
||||||
|
|
||||||
|
# Light colors
|
||||||
|
export LIGHT_GRAY='\033[0;37m'
|
||||||
|
export LIGHT_RED='\033[0;91m'
|
||||||
|
export LIGHT_GREEN='\033[0;92m'
|
||||||
|
export LIGHT_BLUE='\033[0;94m'
|
||||||
|
export LIGHT_YELLOW='\033[0;93m'
|
||||||
|
export LIGHT_MAGENTA='\033[0;95m'
|
||||||
|
export LIGHT_CYAN='\033[0;96m'
|
||||||
|
|
||||||
|
# Bold basic colors
|
||||||
|
export BOLD_BLACK='\033[1;30m'
|
||||||
|
export BOLD_GRAY='\033[1;90m'
|
||||||
|
export BOLD_RED='\033[1;31m'
|
||||||
|
export BOLD_GREEN='\033[1;32m'
|
||||||
|
export BOLD_BLUE='\033[1;34m'
|
||||||
|
export BOLD_YELLOW='\033[1;33m'
|
||||||
|
export BOLD_MAGENTA='\033[1;35m'
|
||||||
|
export BOLD_CYAN='\033[1;36m'
|
||||||
|
export BOLD_WHITE='\033[1;37m'
|
||||||
|
|
||||||
# Styles
|
# Styles
|
||||||
|
|
||||||
export BOLD='\033[1m'
|
export BOLD='\033[1m'
|
||||||
export UNDERLINE='\033[4m'
|
export UNDERLINE='\033[4m'
|
||||||
export BLINK='\033[5m'
|
export BLINK='\033[5m'
|
||||||
export NC='\033[0m' # no Color
|
|
||||||
|
@ -2,27 +2,36 @@
|
|||||||
|
|
||||||
source colors.sh
|
source colors.sh
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
# there can be a function that uses the colors
|
||||||
|
function info() { printf "${MAGENTA}$@${NC}\n"; }
|
||||||
|
function warn() { printf "${BOLD_YELLOW}$@${NC}\n"; }
|
||||||
|
function error() { printf "${BOLD_RED}$@${NC}\n"; }
|
||||||
|
function debug() { printf "${BOLD_GRAY}$@${NC}\n"; }
|
||||||
|
|
||||||
|
info "This is a info test"
|
||||||
|
warn "This is a warn test"
|
||||||
|
error "This is a error test"
|
||||||
|
debug "This is a debug test"
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
## Color print function
|
||||||
|
|
||||||
|
function cprint() { printf "$1$2${NC}\n"; }
|
||||||
|
cprint $RED "This is red text"
|
||||||
|
cprint $BOLD_MAGENTA "Bold magenta text"
|
||||||
|
cprint $BOLD_YELLOW "Bold yellow text"
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
for color in $BLACK $GRAY $RED $GREEN $BLUE $YELLOW $MAGENTA $CYAN $WHITE; do
|
||||||
|
printf "$color%s${NC}\n" "Test color text"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "-----------------------------------------------------------------------------"
|
||||||
|
|
||||||
# with colors.sh sourced, you can use the constants
|
# with colors.sh sourced, you can use the constants
|
||||||
echo "${RED}This is red text${NC} and this is ${GREEN}green ${BLINK}blink${NC} text${NC}"
|
echo "${RED}This is red text${NC} and this is ${GREEN}green ${BLINK}blink${NC} text${NC}"
|
||||||
echo "this is ${MAGENTA}magenta ${BLINK}blink${NC} text${NC}"
|
echo "this is ${MAGENTA}magenta ${BLINK}blink${NC} text${NC}"
|
||||||
|
|
||||||
# there can be a function that uses the colors
|
|
||||||
function info() { printf "${YELLOW}$@${NC}\n"; }
|
|
||||||
info "This is a info test"
|
|
||||||
|
|
||||||
# or you can use the functions directly
|
|
||||||
printf "${GRAY}GRAY${NC}\n"
|
|
||||||
printf "${LIGHT_GRAY}LIGHT_GRAY${NC}\n"
|
|
||||||
printf "${YELLOW}YELLOW${NC}\n"
|
|
||||||
printf "${LIGHT_YELLOW}LIGHT_YELLOW${NC}\n"
|
|
||||||
printf "${GREEN}GREEN${NC}\n"
|
|
||||||
printf "${LIGHT_GREEN}LIGHT_GREEN${NC}\n"
|
|
||||||
printf "${RED}RED${NC}\n"
|
|
||||||
printf "${LIGHT_RED}LIGHT_RED${NC}\n"
|
|
||||||
printf "${BLUE}BLUE${NC}\n"
|
|
||||||
printf "${LIGHT_BLUE}LIGHT_BLUE${NC}\n"
|
|
||||||
printf "${MAGENTA}MAGENTA${NC}\n"
|
|
||||||
printf "${LIGHT_MAGENTA}LIGHT_MAGENTA${NC}\n"
|
|
||||||
printf "${CYAN}CYAN${NC}\n"
|
|
||||||
printf "${WHITE}WHITE${NC}\n"
|
|
||||||
printf "${BLACK}BLACK${NC}\n"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user