Remove functions

This commit is contained in:
Roman Ožana
2023-10-30 15:51:36 +01:00
parent 0082c25fea
commit 18b8f5ee27
3 changed files with 26 additions and 65 deletions
+19 -36
View File
@@ -6,42 +6,25 @@
# License: MIT
# Define Colors
GRAY='\033[0;90m'
LIGHT_GRAY='\033[0;90m'
YELLOW='\033[0;33m'
LIGHT_YELLOW='\033[0;93m'
GREEN='\033[0;32m'
LIGHT_GREEN='\033[0;92m'
RED='\033[0;31m'
LIGHT_RED='\033[0;91m'
BLUE='\033[0;34m'
LIGHT_BLUE='\033[0;94m'
MAGENTA='\033[0;35m'
LIGHT_MAGENTA='\033[0;95m'
CYAN='\033[0;36m'
WHITE='\033[0;37m'
BLACK='\033[0;30m'
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 LIGHT_RED='\033[0;91m'
export BLUE='\033[0;34m'
export LIGHT_BLUE='\033[0;94m'
export MAGENTA='\033[0;35m'
export LIGHT_MAGENTA='\033[0;95m'
export CYAN='\033[0;36m'
export WHITE='\033[0;37m'
export BLACK='\033[0;30m'
# Styles
BOLD='\033[1m'
UNDERLINE='\033[4m'
BLINK='\033[5m'
NC='\033[0m' # no Color
# Define Functions
function gray() { printf "${GRAY}%s${NC}" "$@"; }
function light_gray() { printf "${LIGHT_GRAY}%s${NC}" "$@"; }
function yellow() { printf "${YELLOW}%s${NC}" "$@"; }
function light_yellow() { printf "${LIGHT_YELLOW}%s${NC}" "$@"; }
function green() { printf "${GREEN}%s${NC}" "$@"; }
function light_green() { printf "${LIGHT_GREEN}%s${NC}" "$@"; }
function red() { printf "${RED}%s${NC}" "$@"; }
function light_red() { printf "${LIGHT_RED}%s${NC}" "$@"; }
function blue() { printf "${BLUE}%s${NC}" "$@"; }
function light_blue() { printf "${LIGHT_BLUE}%s${NC}" "$@"; }
function magenta() { printf "${MAGENTA}%s${NC}" "$@"; }
function light_magenta() { printf "${LIGHT_MAGENTA}%s${NC}" "$@"; }
function cyan() { printf "${CYAN}%s${NC}" "$@"; }
function white() { printf "${WHITE}%s${NC}" "$@"; }
function black() { printf "${BLACK}%s${NC}" "$@"; }
export BOLD='\033[1m'
export UNDERLINE='\033[4m'
export BLINK='\033[5m'
export NC='\033[0m' # no Color
+1 -5
View File
@@ -6,15 +6,11 @@ source colors.sh
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}"
# or you can use the functions
echo $(gray "[INFO] " && green "This is green test")
# there can be a function that uses the colors
function info() { echo $(gray "[INFO] " && yellow "$@"); }
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"
+6 -24
View File
@@ -8,37 +8,19 @@ Write colored text to the terminal easily.
Download `colors.sh` and source it in your script or copy/paste the functions and variables into your script.
```shell
curl -O https://raw.githubusercontent.com/OzzyCzech/colors.sh/master/colors.sh
```
## Usage
```sh
```shell
source colors.sh
# with colors.sh sourced, you can use the constants
echo "${RED}This is red text${NC}"
# or you can use the functions
echo $(gray "[INFO] " && green "This is green test")
echo "This is ${RED}red text${NC}"
```
## Functions
- `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
- `ligt_red` - for ligt 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
- `nc` - for no colors (reset)
## Contants
- `GRAY` - for gray