mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 21:23:38 +00:00
35 lines
720 B
Bash
35 lines
720 B
Bash
|
function setupColors() {
|
||
|
normalColor=""
|
||
|
errorColor=""
|
||
|
warnColor=""
|
||
|
noteColor=""
|
||
|
|
||
|
# Check if stdout is a terminal.
|
||
|
if [[ -t 1 ]]; then
|
||
|
# See if it supports colors.
|
||
|
local ncolors
|
||
|
ncolors=$(tput colors)
|
||
|
|
||
|
if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then
|
||
|
normalColor="$(tput sgr0)"
|
||
|
errorColor="$(tput bold)$(tput setaf 1)"
|
||
|
warnColor="$(tput setaf 3)"
|
||
|
noteColor="$(tput bold)$(tput setaf 6)"
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
setupColors
|
||
|
|
||
|
function errorEcho() {
|
||
|
echo "${errorColor}$*${normalColor}"
|
||
|
}
|
||
|
|
||
|
function warnEcho() {
|
||
|
echo "${warnColor}$*${normalColor}"
|
||
|
}
|
||
|
|
||
|
function noteEcho() {
|
||
|
echo "${noteColor}$*${normalColor}"
|
||
|
}
|