|
|
|
|
|
by jamesponddotco
2090 days ago
|
|
Personally, I love colours on my terminal — in a minimal way, like this[1] —, but
I understand people that do not, which is why I have this in every script I
write, public or not. # Color variables to make our output a little easier on the eyes. Respect
# NO_COLOR, in case the user does not want any.
if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
readonly c_red='\033[0;31m'
readonly c_blue='\033[0;34m'
readonly c_green='\033[0;32m'
readonly c_bold='\033[1m'
readonly c_reset='\033[0m'
fi
I have no idea why I added that readonly command there, though, but by now I am
afraid to remove it.The NO_COLOR[2] environment variable is not exactly a standard as far as I know, but it is supported by enough command-line software that it feels like one to me. [1] https://i.cpimg.sh/9k3PlfHt1Spg.png [2] https://no-color.org/ |
|