lib: Add _has_colors function and use it in log output

This commit is contained in:
Noah Gorny
2020-06-23 15:42:22 +03:00
parent 862c154793
commit 3e7a95660f
2 changed files with 16 additions and 5 deletions

View File

@@ -1,5 +1,15 @@
#!/usr/bin/env bash
function _has_colors()
{
# Check that stdout is a terminal
test -t 1 || return 1
ncolors=$(tput colors)
test -n "$ncolors" && test "$ncolors" -ge 8 || return 1
return 0
}
# colored ls
export LSCOLORS='Gxfxcxdxdxegedabagacad'