local safe_term="${TERM//[^[:alnum:]]/?}"
local match_lhs=""
local use_color="false"
- [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
- [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
- [[ -z ${match_lhs} ]] \
- && type -P dircolors >/dev/null \
- && match_lhs=$(dircolors --print-database)
- [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color="true"
+ local term=
+
+ if [[ -f ~/.dir_colors ]] ; then
+ match_lhs="${match_lhs}$( cat ~/.dir_colors | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')"
+ fi
+ if [[ -f /etc/DIR_COLORS ]] ; then
+ match_lhs="${match_lhs}$( cat /etc/DIR_COLORS | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')"
+ fi
+ if [[ -z ${match_lhs} ]] ; then
+ type -P dircolors >/dev/null && \
+ match_lhs=$(dircolors --print-database | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')
+ fi
+ for term in ${match_lhs} ; do
+ if [[ "${safe_term}" == ${term} || "${TERM}" == ${term} ]] ; then
+ use_color="true"
+ break
+ fi
+ done
# console colors:
if [ "${use_color}" = "true" ] ; then
if [[ "${VERBOSE}" != "y" ]] ; then
return 0
fi
- echo -e " * [$(my_date)] [${BASE_NAME}:DEBUG]: $@" >&2
+ echo -e " * [$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
}
#------------------------------------------------------------------------------