Created
September 2, 2023 16:08
-
-
Save viega/f3ad2993597619d3323e43f51448e9e4 to your computer and use it in GitHub Desktop.
My bash function(s) for colorizing test in shell scripts.
This file contains hidden or 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
function color { | |
case $1 in | |
black) CODE=0 ;; | |
red) CODE=1 ;; RED) CODE=9 ;; | |
green) CODE=2 ;; GREEN) CODE=10 ;; | |
yellow) CODE=3 ;; YELLOW) CODE=11 ;; | |
blue) CODE=4 ;; BLUE) CODE=12 ;; | |
magenta) CODE=5 ;; MAGENTA) CODE=13 ;; | |
cyan) CODE=6 ;; CYAN) CODE=14 ;; | |
white) CODE=7 ;; WHITE) CODE=15 ;; | |
grey) CODE=8 ;; *) CODE=$1 ;; | |
esac | |
shift | |
echo -n $(tput setaf ${CODE})$@$(tput op) | |
} | |
function colorln { | |
echo $(color $@) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can do things like: