当前位置: 移动技术网 > 科技>操作系统>Linux > shell日志颜色处理

shell日志颜色处理

2018年09月27日  | 移动技术网科技  | 我要评论

音乐推荐系统,亡骑咆哮txt,麦当劳薯条买一送一

记录一下shell日志颜色处理

_colors=${bs_colors:-$(tput colors 2>/dev/null || echo 0)}
__detect_color_support() {
    # shellcheck disable=sc2181
    if [ $? -eq 0 ] && [ "$_colors" -gt 2 ]; then
        rc='\033[1;31m'
        gc='\033[1;32m'
        bc='\033[1;34m'
        yc='\033[1;33m'
        ec='\033[0m'
    else
        rc=""
        gc=""
        bc=""
        yc=""
        ec=""
    fi
}
__detect_color_support
echoerror() {
    printf "${rc} * error${ec}: %s\\n" "$@" 1>&2;
}
echoinfo() {
    printf "${gc} *  info${ec}: %s\\n" "$@";
}
echowarn() {
    printf "${yc} *  warn${ec}: %s\\n" "$@";
}

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网