Created
August 29, 2022 07:53
-
-
Save KunalSin9h/cd2ac276ddbb2131287b8ec2f426e618 to your computer and use it in GitHub Desktop.
This is colour output snippet for shell script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Reset | |
Color_Off='' | |
# Regular Colors | |
Red='' | |
Green='' | |
Yellow='' | |
Cyan='' | |
Magenta='' | |
Dim='' # White | |
# Bold | |
Bold_White='' | |
Bold_Green='' | |
if [[ -t 1 ]]; then | |
# Reset | |
Color_Off='\033[0m' # Text Reset | |
# Regular Colors | |
Red='\033[0;31m' # Red | |
Green='\033[0;32m' # Green | |
Yellow='\033[1;33m' # Yellow | |
Cyan='\033[0;36m' | |
Magenta='\033[1;35m' | |
Dim='\033[0;2m' # White | |
# Bold | |
Bold_Green='\033[1;32m' # Bold Green | |
Bold_White='\033[1m' # Bold White | |
fi | |
error() { | |
echo -e "${Red}error${Color_Off}:" "$@" >&2 | |
exit 1 | |
} | |
info() { | |
echo -e "${Dim}$@ ${Color_Off}" | |
} | |
info_bold() { | |
echo -e "${Bold_White}$@ ${Color_Off}" | |
} | |
success() { | |
echo -e "${Green}$@ ${Color_Off}" | |
} | |
bold_success() { | |
echo -e "${Bold_Green}$@ ${Color_Off}" | |
} | |
intro() { | |
echo -e "${Yellow}$@ ${Color_Off}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more example