欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux sh : print color text

程序员文章站 2022-06-01 10:53:18
...

前言

本来要写安装程序的,突然想到,要将安装过程中的信息文本打印的好看点。
在linux脚本中调用printf 或 echo -e 时,可以直接加入显示控制字符,用来显示彩色文本。
如果要大量的显示彩色文本,就需要封装一下,提高可维护性。
搞了一天,封装了一组好用的彩色文本打印接口。将自己需要的各种情况都考虑到了。
只是没有想到需要这么长时间来封装,意外…

运行效果

linux sh : print color text

测试工程

#!/bin/bash --posix

# @file make_linux_installation_program.sh

. ./helper/sh.ini_file_opt
. ./helper/sh.env_check
. ./helper/sh.color_define

function func_test_color_print() {
    # test all kind of color print
    test_color_all

    echo "# -------------------------------------------------------------------------------"
    echo "# test print color text"
    echo "# -------------------------------------------------------------------------------"
    PRINT_BLACK "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_RED "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_GREEN "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_YELLOW "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_BLUE "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_MAGENTA "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_CYAN "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_WHITE "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color print interface by printf"
    echo "# -------------------------------------------------------------------------------"
    PRINT_COLOR_INFO "this is a info text : current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_COLOR_WARN "this is a warning text"
    PRINT_COLOR_ERR "this is a error text"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color print interface by echo"
    echo "# -------------------------------------------------------------------------------"
    ECHO_COLOR_INFO "this is a normal text : current user id = " $(id -u) ", user name = " $(id -u -n)
    ECHO_COLOR_WARN "this is a warning text"
    ECHO_COLOR_ERR "this is a error text"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color begin and color end, between them, can call print or echo print color text"
    echo "# -------------------------------------------------------------------------------"

    COLOR_BEGIN_INFO
    echo -e "* this is a info text"
    printf "** this is a info text : current user id = %d, user name = %s\n" "$(id -u)" "$(id -u -n)"
    echo -e "*** before do COLOR_END, when finish a row, don't use /n on the end"
    COLOR_END

    COLOR_BEGIN_WARN
    printf "* this is a warning text : current user id = %d, user name = %s\n" $(id -u) "$(id -u -n)"
    echo -e "** this is a warning text"
    echo -e "*** before do COLOR_END, when finish a row, don't use /n on the end"
    COLOR_END

    COLOR_BEGIN_ERR
    echo -e "* this is a error text"
    echo -e "** before do COLOR_END, when finish a row, don't use /n on the end"
    printf "*** this is a error text : current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    COLOR_END

    printf "test end\n"
}

function main() {
    local rv=""
    local rc=0
    local str_cmd=""

    clear

    echo "execute make_linux_installation_program.sh..."
    func_test_color_print

    echo "execute make_linux_installation_program.sh END"
    return 0
}

main
exit 0

接口库

# @file sh.color_define
# @brief print color text
#   when print color text, don't use "\r" or "\n" to end the echo or printf, 
#   after echo or print, the warp will be to next row
#   e.g. 
<< MY_NOTE
function func_test_color_print() {
    # test all kind of color print
    test_color_all

    echo "# -------------------------------------------------------------------------------"
    echo "# test print color text"
    echo "# -------------------------------------------------------------------------------"
    PRINT_BLACK "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_RED "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_GREEN "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_YELLOW "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_BLUE "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_MAGENTA "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_CYAN "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_WHITE "current user id = %d, user name = %s" $(id -u) "$(id -u -n)"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color print interface by printf"
    echo "# -------------------------------------------------------------------------------"
    PRINT_COLOR_INFO "this is a info text : current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    PRINT_COLOR_WARN "this is a warning text"
    PRINT_COLOR_ERR "this is a error text"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color print interface by echo"
    echo "# -------------------------------------------------------------------------------"
    ECHO_COLOR_INFO "this is a normal text : current user id = " $(id -u) ", user name = " $(id -u -n)
    ECHO_COLOR_WARN "this is a warning text"
    ECHO_COLOR_ERR "this is a error text"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color begin and color end, between them, can call print or echo print color text"
    echo "# -------------------------------------------------------------------------------"

    COLOR_BEGIN_INFO
    echo -e "* this is a info text"
    printf "** this is a info text : current user id = %d, user name = %s\n" "$(id -u)" "$(id -u -n)"
    echo -e "*** before do COLOR_END, when finish a row, don't use /n on the end"
    COLOR_END

    COLOR_BEGIN_WARN
    printf "* this is a warning text : current user id = %d, user name = %s\n" $(id -u) "$(id -u -n)"
    echo -e "** this is a warning text"
    echo -e "*** before do COLOR_END, when finish a row, don't use /n on the end"
    COLOR_END

    COLOR_BEGIN_ERR
    echo -e "* this is a error text"
    echo -e "** before do COLOR_END, when finish a row, don't use /n on the end"
    printf "*** this is a error text : current user id = %d, user name = %s" $(id -u) "$(id -u -n)"
    COLOR_END

    printf "test end\n"
}
MY_NOTE

# --------------------------------------------------------------------------------
# color basic define
# --------------------------------------------------------------------------------

<<MY_NOTE
                foreground background
black           30          40      # 黑
red             31          41      # 红
green           32          42      # 绿
yellow          33          43      # 黄
blue            34          44      # 蓝
magenta         35          45      # 品红
cyan            36          46      # 青
light gray      37          47      # 亮灰
default color   39          49      # 默认颜色
dark gray       90          100     # 深灰
light red       91          101     # 浅红
light green     92          102     # 浅绿
light yellow    93          103     # 浅黄
light blue      94          104     # 浅蓝
light magenta   95          105     # 洋红
light cyan      96          106     # 浅青
white           97          107     # 白

MY_NOTE

# color value - foreground
COLOR_TYPE_FG_BLACK="\e[30m"
COLOR_TYPE_FG_RED="\e[31m"
COLOR_TYPE_FG_GREEN="\e[32m"
COLOR_TYPE_FG_YELLOW="\e[33m"
COLOR_TYPE_FG_BLUE="\e[34m"
COLOR_TYPE_FG_MAGENTA="\e[35m"
COLOR_TYPE_FG_CYAN="\e[36m"
COLOR_TYPE_FG_LIGHT_GRAY="\e[37m"
COLOR_TYPE_FG_DEFAULT_COLOR="\e[39m"
COLOR_TYPE_FG_DARK_GRAY="\e[90m"
COLOR_TYPE_FG_LIGHT_RED="\e[91m"
COLOR_TYPE_FG_LIGHT_GREEN="\e[92m"
COLOR_TYPE_FG_LIGHT_YELLOW="\e[93m"
COLOR_TYPE_FG_LIGHT_BLUE="\e[94m"
COLOR_TYPE_FG_LIGHT_MAGENTA="\e[95m"
COLOR_TYPE_FG_LIGHT_CYAN="\e[96m"
COLOR_TYPE_FG_WHITE="\e[97m"

# color value - background
COLOR_TYPE_BG_BLACK="\e[40m"
COLOR_TYPE_BG_RED="\e[41m"
COLOR_TYPE_BG_GREEN="\e[42m"
COLOR_TYPE_BG_YELLOW="\e[43m"
COLOR_TYPE_BG_BLUE="\e[44m"
COLOR_TYPE_BG_MAGENTA="\e[45m"
COLOR_TYPE_BG_CYAN="\e[46m"
COLOR_TYPE_BG_LIGHT_GRAY="\e[47m"
COLOR_TYPE_BG_DEFAULT_COLOR="\e[49m"
COLOR_TYPE_BG_DARK_GRAY="\e[100m"
COLOR_TYPE_BG_LIGHT_RED="\e[101m"
COLOR_TYPE_BG_LIGHT_GREEN="\e[102m"
COLOR_TYPE_BG_LIGHT_YELLOW="\e[103m"
COLOR_TYPE_BG_LIGHT_BLUE="\e[104m"
COLOR_TYPE_BG_LIGHT_MAGENTA="\e[105m"
COLOR_TYPE_BG_LIGHT_CYAN="\e[106m"
COLOR_TYPE_BG_WHITE="\e[107m"

# color attrib set
COLOR_ATTRIB_BOLD="\e[1m"       # 粗体
COLOR_ATTRIB_DIM="\e[2m"        # 暗淡
COLOR_ATTRIB_UNDER_LINE="\e[4m" # 下划线
COLOR_ATTRIB_BLINK="\e[5m"      # 闪烁
COLOR_ATTRIB_REVERSE="\e[7m"    # 颜色反转(前景色和背景色色交换)
COLOR_ATTRIB_HIDDEN="\e[8m"     # 隐藏文本, 用于口令的显示

# color attrib reset
COLOR_RESET="\e[0m"

# --------------------------------------------------------------------------------
# color function define
# --------------------------------------------------------------------------------

function func_parameter_forwarding_to_echo() {
    echo -e ${@:1}
    return 0
}

function func_parameter_forwarding_to_printf() {
    # printf 参数转发时, 参数1要用双引号围住
    printf "$(echo $1)" $(echo ${@:2})
    echo
    return 0
}

# --------------------------------------------------------------------------------
# app color function define
# --------------------------------------------------------------------------------

<<MY_NOTE
    调用print_color_text_x()时, 是按照printf函数调用的格式来的
    得到参数1, 加入颜色控制符, 连同剩下的入参, 转发给printf
    # ${@:2} is content from parameter 2 to last parameter
MY_NOTE

# --------------------------------------------------------------------------------
# app color function define - test all color
# --------------------------------------------------------------------------------
function test_color_all() {
    local color_format_parameter=""
    local color_to_test=""

    echo "# -------------------------------------------------------------------------------"
    echo "# test color fg"
    echo "# -------------------------------------------------------------------------------"

    color_to_test=$COLOR_TYPE_FG_BLACK$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_BLACK"

    color_to_test=$COLOR_TYPE_FG_RED$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_RED"

    color_to_test=$COLOR_TYPE_FG_GREEN$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_GREEN"

    color_to_test=$COLOR_TYPE_FG_YELLOW$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_YELLOW"

    color_to_test=$COLOR_TYPE_FG_BLUE$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_BLUE"

    color_to_test=$COLOR_TYPE_FG_MAGENTA$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_MAGENTA"

    color_to_test=$COLOR_TYPE_FG_CYAN$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_CYAN"

    color_to_test=$COLOR_TYPE_FG_LIGHT_GRAY$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_GRAY"

    color_to_test=$COLOR_TYPE_FG_DEFAULT_COLOR$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_DEFAULT_COLOR"

    color_to_test=$COLOR_TYPE_FG_DARK_GRAY$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_DARK_GRAY"

    color_to_test=$COLOR_TYPE_FG_LIGHT_RED$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_RED"

    color_to_test=$COLOR_TYPE_FG_LIGHT_GREEN$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_GREEN"

    color_to_test=$COLOR_TYPE_FG_LIGHT_YELLOW$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_YELLOW"

    color_to_test=$COLOR_TYPE_FG_LIGHT_BLUE$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_BLUE"

    color_to_test=$COLOR_TYPE_FG_LIGHT_MAGENTA$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_MAGENTA"

    color_to_test=$COLOR_TYPE_FG_LIGHT_CYAN$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_LIGHT_CYAN"

    color_to_test=$COLOR_TYPE_FG_WHITE$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_FG_WHITE"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color bg"
    echo "# -------------------------------------------------------------------------------"

    color_to_test=$COLOR_TYPE_BG_BLACK$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_BLACK"

    color_to_test=$COLOR_TYPE_BG_RED$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_RED"

    color_to_test=$COLOR_TYPE_BG_GREEN$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_GREEN"

    color_to_test=$COLOR_TYPE_BG_YELLOW$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_YELLOW"

    color_to_test=$COLOR_TYPE_BG_BLUE$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_BLUE"

    color_to_test=$COLOR_TYPE_BG_MAGENTA$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_MAGENTA"

    color_to_test=$COLOR_TYPE_BG_CYAN$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_CYAN"

    color_to_test=$COLOR_TYPE_BG_LIGHT_GRAY$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_GRAY"

    color_to_test=$COLOR_TYPE_BG_DEFAULT_COLOR$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_DEFAULT_COLOR"

    color_to_test=$COLOR_TYPE_BG_DARK_GRAY$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_DARK_GRAY"

    color_to_test=$COLOR_TYPE_BG_LIGHT_RED$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_RED"

    color_to_test=$COLOR_TYPE_BG_LIGHT_GREEN$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_GREEN"

    color_to_test=$COLOR_TYPE_BG_LIGHT_YELLOW$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_YELLOW"

    color_to_test=$COLOR_TYPE_BG_LIGHT_BLUE$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_BLUE"

    color_to_test=$COLOR_TYPE_BG_LIGHT_MAGENTA$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_MAGENTA"

    color_to_test=$COLOR_TYPE_BG_LIGHT_CYAN$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_LIGHT_CYAN"

    color_to_test=$COLOR_TYPE_BG_WHITE$COLOR_TYPE_FG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_TYPE_BG_WHITE"

    echo "# -------------------------------------------------------------------------------"
    echo "# test color attrib set"
    echo "# -------------------------------------------------------------------------------"
    color_to_test=$COLOR_ATTRIB_BOLD$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_BOLD"

    color_to_test=$COLOR_ATTRIB_DIM$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_DIM"

    color_to_test=$COLOR_ATTRIB_UNDER_LINE$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_UNDER_LINE"

    color_to_test=$COLOR_ATTRIB_BLINK$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_BLINK"

    color_to_test=$COLOR_ATTRIB_REVERSE$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_REVERSE"

    color_to_test=$COLOR_ATTRIB_HIDDEN$COLOR_TYPE_BG_DEFAULT_COLOR
    color_format_parameter="$color_to_test%s$COLOR_RESET"
    func_parameter_forwarding_to_printf "$color_format_parameter" "COLOR_ATTRIB_HIDDEN"

    return 0
}

# --------------------------------------------------------------------------------
# app color function define - set foreground color
# --------------------------------------------------------------------------------

alias PRINT_BLACK="print_color_text_black"
function print_color_text_black() {
    # bg = default, fg = black
    local new_parameter_1="$COLOR_TYPE_FG_BLACK$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_RED="print_color_text_red"
function print_color_text_red() {
    # bg = default, fg = red
    local new_parameter_1="$COLOR_TYPE_FG_RED$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_GREEN="print_color_text_green"
function print_color_text_green() {
    # bg = default, fg = green
    local new_parameter_1="$COLOR_TYPE_FG_GREEN$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_YELLOW="print_color_text_yellow"
function print_color_text_yellow() {
    # bg = default, fg = yellow
    local new_parameter_1="$COLOR_TYPE_FG_YELLOW$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_BLUE="print_color_text_blue"
function print_color_text_blue() {
    # bg = default, fg = blue
    local new_parameter_1="$COLOR_TYPE_FG_BLUE$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_MAGENTA="print_color_text_magenta"
function print_color_text_magenta() {
    # bg = default, fg = magenta
    local new_parameter_1="$COLOR_TYPE_FG_MAGENTA$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_CYAN="print_color_text_cyan"
function print_color_text_cyan() {
    # bg = default, fg = cyan
    local new_parameter_1="$COLOR_TYPE_FG_CYAN$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_WHITE="print_color_text_white"
function print_color_text_white() {
    # bg = default, fg = white
    local new_parameter_1="$COLOR_TYPE_FG_WHITE$COLOR_TYPE_BG_DEFAULT_COLOR$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

# --------------------------------------------------------------------------------
# app color function define - as log level - by printf
# --------------------------------------------------------------------------------
alias PRINT_COLOR_INFO="print_color_text_info"
function print_color_text_info() {
    # fg = green
    PRINT_GREEN "$1" $(echo ${@:2})
    return 0
}

alias PRINT_COLOR_WARN="print_color_text_warning"
function print_color_text_warning() {
    # fg = black, bg = yellow, bold
    local new_parameter_1="$COLOR_TYPE_FG_BLACK$COLOR_TYPE_BG_YELLOW$COLOR_ATTRIB_HOLD$COLOR_ATTRIB_UNDER_LINE$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

alias PRINT_COLOR_ERR="print_color_text_error"
function print_color_text_error() {
    # fg = white, bg = red, blink, bold
    local new_parameter_1="$COLOR_TYPE_FG_WHITE$COLOR_TYPE_BG_RED$COLOR_ATTRIB_BLINK$COLOR_ATTRIB_HOLD$1$COLOR_RESET"

    func_parameter_forwarding_to_printf "$new_parameter_1" $(echo ${@:2})
    return 0
}

# --------------------------------------------------------------------------------
# app color function define - as log level - by echo
# --------------------------------------------------------------------------------
alias ECHO_COLOR_INFO="echo_color_text_info"
function echo_color_text_info() {
    # fg = green, bg = default
    local new_parameter="$COLOR_TYPE_FG_GREEN$COLOR_TYPE_BG_DEFAULT_COLOR$(echo ${@:1})$COLOR_RESET"

    func_parameter_forwarding_to_echo $new_parameter
    return 0
}

alias ECHO_COLOR_WARN="echo_color_text_warning"
function echo_color_text_warning() {
    # fg = black, bg = yellow, bold, under line
    local new_parameter="$COLOR_TYPE_FG_BLACK$COLOR_TYPE_BG_YELLOW$COLOR_ATTRIB_HOLD$COLOR_ATTRIB_UNDER_LINE$(echo ${@:1})$COLOR_RESET"

    func_parameter_forwarding_to_echo $new_parameter
    return 0
}

alias ECHO_COLOR_ERR="echo_color_text_error"
function echo_color_text_error() {
    # fg = white, bg = red, blink, bold
    local new_parameter="$COLOR_TYPE_FG_WHITE$COLOR_TYPE_BG_RED$COLOR_ATTRIB_BLINK$COLOR_ATTRIB_HOLD$(echo ${@:1})$COLOR_RESET"

    func_parameter_forwarding_to_echo $new_parameter
    return 0
}

# --------------------------------------------------------------------------------
# only set color or reset color
# between set color and reset color, can call printf or echo text, the text is color
# --------------------------------------------------------------------------------
alias COLOR_BEGIN_INFO="func_color_begin_info"
function func_color_begin_info() {
    # fg = green, bg = default
    local new_parameter="$COLOR_TYPE_FG_GREEN$COLOR_TYPE_BG_DEFAULT_COLOR"

    echo -e $new_parameter
    return 0
}

alias COLOR_BEGIN_WARN="func_color_begin_warning"
function func_color_begin_warning() {
    # fg = black, bg = yellow, bold, under line
    local new_parameter="$COLOR_TYPE_FG_BLACK$COLOR_TYPE_BG_YELLOW$COLOR_ATTRIB_HOLD$COLOR_ATTRIB_UNDER_LINE"

    echo -e $new_parameter
    return 0
}

alias COLOR_BEGIN_ERR="func_color_begin_error"
function func_color_begin_error() {
    # fg = white, bg = red, blink, bold
    local new_parameter="$COLOR_TYPE_FG_WHITE$COLOR_TYPE_BG_RED$COLOR_ATTRIB_BLINK$COLOR_ATTRIB_HOLD"

    echo -e $new_parameter
    return 0
}

alias COLOR_END="func_color_end"
function func_color_end() {
    local new_parameter="$COLOR_RESET"

    echo -e $new_parameter
    return 0
}