Colors upgrade
This commit is contained in:
parent
4910216ec2
commit
c2b01dfb75
BIN
colors.png
BIN
colors.png
Binary file not shown.
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 121 KiB |
28
colors.sh
28
colors.sh
@ -5,37 +5,35 @@
|
||||
# Author: Roman Ožana <roman@ozana.cz>
|
||||
# License: MIT
|
||||
|
||||
# Basic colors
|
||||
# Black and white
|
||||
export BLACK='\033[0;30m'
|
||||
export WHITE='\033[0;37m'
|
||||
export GRAY='\033[0;90m'
|
||||
export NC='\033[0m' # reset color
|
||||
|
||||
# Basic colors
|
||||
export RED='\033[0;31m'
|
||||
export GREEN='\033[0;32m'
|
||||
export BLUE='\033[0;34m'
|
||||
export YELLOW='\033[0;33m'
|
||||
export MAGENTA='\033[0;35m'
|
||||
export CYAN='\033[0;36m'
|
||||
export WHITE='\033[0;37m'
|
||||
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'
|
||||
# Bright colors
|
||||
export BRIGHT_RED='\033[0;91m'
|
||||
export BRIGHT_GREEN='\033[0;92m'
|
||||
export BRIGHT_BLUE='\033[0;94m'
|
||||
export BRIGHT_YELLOW='\033[0;93m'
|
||||
export BRIGHT_MAGENTA='\033[0;95m'
|
||||
export BRIGHT_CYAN='\033[0;96m'
|
||||
|
||||
# Bold basic colors
|
||||
export BOLD_BLACK='\033[1;30m'
|
||||
export BOLD_GRAY='\033[1;90m'
|
||||
# Bold colors
|
||||
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
|
||||
export BOLD='\033[1m'
|
||||
|
@ -5,40 +5,53 @@ 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"; }
|
||||
function success() { printf "${BOLD_GREEN}$@${NC}\n"; }
|
||||
function info() { printf "${BOLD_CYAN}%s${NC}\n" "$@"; }
|
||||
function warn() { printf "${BOLD_YELLOW}%s${NC}\n" "$@"; }
|
||||
function error() { printf "${BOLD_RED}%s${NC}\n" "$@"; }
|
||||
function debug() { printf "${BOLD_GRAY}%s${NC}\n" "$@"; }
|
||||
function success() { printf "${BOLD_GREEN}%s${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"
|
||||
info "[INFO] This is info text"
|
||||
warn "[WARN] This is warn text"
|
||||
error "[ERROR] This is error text"
|
||||
debug "[DEBUG] This is debug text"
|
||||
|
||||
echo "-----------------------------------------------------------------------------"
|
||||
|
||||
echo -e "${GRAY}-----------------------------------------------------------------------------${NC}"
|
||||
|
||||
## 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"
|
||||
function color() { printf "$1%s${NC}\n" "$2";}
|
||||
color "$RED" "This is red text"
|
||||
color "$BOLD_MAGENTA" "Bold magenta text"
|
||||
color "$BOLD_YELLOW" "Bold yellow text"
|
||||
|
||||
echo "-----------------------------------------------------------------------------"
|
||||
echo -e "${GRAY}-----------------------------------------------------------------------------${NC}"
|
||||
|
||||
for color in $BLACK $GRAY $RED $GREEN $BLUE $YELLOW $MAGENTA $CYAN $WHITE; do
|
||||
printf "$color%s${NC}\n" "Test color text"
|
||||
done
|
||||
echo -e "${BLACK}Black color text${NC}"
|
||||
echo -e "${WHITE}White color text${NC}"
|
||||
|
||||
echo "-----------------------------------------------------------------------------"
|
||||
echo -e "${GRAY}-----------------------------------------------------------------------------${NC}\n\n"
|
||||
|
||||
# Basic colors
|
||||
|
||||
echo -e "${BLACK}BLACK${NC}, ${GRAY}GRAY${NC} or ${WHITE}WHITE${NC} color text"
|
||||
echo -e "${RED}RED${NC} or ${BRIGHT_RED}BRIGHT_RED${NC} color text"
|
||||
echo -e "${GREEN}GREEN${NC} or ${BRIGHT_GREEN}BRIGHT_GREEN${NC} color text"
|
||||
echo -e "${BLUE}BLUE${NC} or ${BRIGHT_BLUE}BRIGHT_BLUE${NC} color text"
|
||||
echo -e "${YELLOW}YELLOW${NC} or ${BRIGHT_YELLOW}BRIGHT_YELLOW${NC} color text"
|
||||
echo -e "${MAGENTA}MAGENTA${NC} or ${BRIGHT_MAGENTA}BRIGHT_MAGENTA${NC} color text"
|
||||
echo -e "${CYAN}CYAN${NC} or ${BRIGHT_CYAN}BRIGHT_CYAN${NC} color text"
|
||||
|
||||
|
||||
|
||||
echo -e "\n\n${GRAY}-----------------------------------------------------------------------------${NC}"
|
||||
|
||||
# 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 "this is ${MAGENTA}magenta ${BLINK}blink${NC} text${NC}"
|
||||
echo -e "${RED}This is ${BOLD}bold red text${NC} and this is ${GREEN}green ${BLINK}blink${NC} text${NC}"
|
||||
echo -e "this is ${MAGENTA}magenta ${BLINK}blink${NC} text${NC}"
|
||||
|
||||
|
||||
echo "-----------------------------------------------------------------------------"
|
||||
echo -e "${GRAY}-----------------------------------------------------------------------------${NC}"
|
||||
|
||||
# Add color to the output of a command
|
||||
{
|
||||
|
22
readme.md
22
readme.md
@ -21,28 +21,6 @@ source colors.sh
|
||||
echo "This is ${RED}red text${NC}"
|
||||
```
|
||||
|
||||
## Contants
|
||||
|
||||
- `GRAY` - for gray
|
||||
- `LIGHT_GRAY` - for light_gray
|
||||
- `YELLOW` - for yellow
|
||||
- `LIGHT_YELLOW` - for light yellow
|
||||
- `GREEN` - for green
|
||||
- `LIGHT_GREEN` - for light green
|
||||
- `RED` - for red
|
||||
- `LIGHT_RED` - for light red
|
||||
- `BLUE` - for blue
|
||||
- `LIGHT_BLUE` - for light blue
|
||||
- `MAGENTA` - for magenta
|
||||
- `LIGHT_MAGENTA` - for light magenta
|
||||
- `CYAN` - for cyan
|
||||
- `WHITE` - for white
|
||||
- `BLACK` - for black
|
||||
- `BOLD` - for bold
|
||||
- `UNDERLINE` - for underline
|
||||
- `BLINK` - for blink
|
||||
- `NC` - for no colors (reset)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
Loading…
Reference in New Issue
Block a user