Last active
February 8, 2024 01:27
-
-
Save neuralpain/f27ff19311ed0466feac46fa721dd391 to your computer and use it in GitHub Desktop.
Predefined functions for displaying colored CLI messages based on type, i.e., success, error and information
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
# extracted from: https://bun.sh/install | |
# https://github.com/oven-sh/bun | |
# Reset | |
Color_Off='' | |
# Regular Colors | |
Red='' | |
Green='' | |
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 | |
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}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment