First commit

This commit is contained in:
Roman Ožana 2023-04-05 17:50:56 +02:00
commit 54d313d518
5 changed files with 142 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Roman Ožana (https://ozana.cz/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

BIN
colors.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

48
colors.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
# This script is used to define colors for bash scripts
# GitHub: https://github.com/OzzyCzech/colors.sh
# Author: Roman Ožana <roman@ozana.cz>
# License: MIT
# Define Functions
function gray() { printf "\e[1;90m%s\e[m" "$@"; }
function light_gray() { printf "\e[1;90m%s\e[m" "$@"; }
function yellow() { printf "\e[1;33m%s\e[m" "$@"; }
function light_yellow() { printf "\e[1;93m%s\e[m" "$@"; }
function green() { printf "\e[1;32m%s\e[m" "$@"; }
function light_green() { printf "\e[1;92m%s\e[m" "$@"; }
function red() { printf "\e[1;31m%s\e[m" "$@"; }
function ligt_red() { printf "\e[1;91m%s\e[m" "$@"; }
function blue() { printf "\e[1;34m%s\e[m" "$@"; }
function light_blue() { printf "\e[1;94m%s\e[m" "$@"; }
function magenta() { printf "\e[1;35m%s\e[m" "$@"; }
function light_magenta() { printf "\e[1;95m%s\e[m" "$@"; }
function cyan() { printf "\e[1;36m%s\e[m" "$@"; }
function white() { printf "\e[1;37m%s\e[m" "$@"; }
function black() { printf "\e[1;30m%s\e[m" "$@"; }
function bold() { printf "\e[1m%s\e[m" "$@"; }
function underline() { printf "\e[4m%s\e[m" "$@"; }
function blink() { printf "\e[5m%s\e[m" "$@"; }
function nc() { printf "\e[0m%s\e[m" "$@"; } # no color
# Define Colors
GRAY='\033[0;37m'
LIGHT_GRAY='\033[0;37m'
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'
BOLD='\033[1m'
UNDERLINE='\033[4m'
BLINK='\033[5m'
NC='\033[0m' # no Color

8
example/usage.sh Executable file
View File

@ -0,0 +1,8 @@
source colors.sh
# 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}"
# or you can use the functions
echo $(gray "[INFO] " && green "This is gree test")

65
readme.md Normal file
View File

@ -0,0 +1,65 @@
# colors.sh
Write colored text to the terminal easily.
![Color palette](colors.png)
## Installation
Download `colors.sh` and source it in your script or copy/paste the functions and variables into your script.
## Usage
```sh
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")
```
## 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
- `bold` - for bold
- `underline` - for underline
- `blink` - for blink text
- `nc` - for no colors (reset)
## 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)