OSDN Git Service

[fix] : Fixed time log
[alterlinux/LUBS.git] / echo_color
1 #!/usr/bin/env bash
2 while getopts 't:b:d:' arg; do
3     case ${arg} in
4         t) textcolor="${OPTARG}" ;;
5         b) backcolor="${OPTARG}" ;;
6         d) deco="${OPTARG}" ;;
7     esac
8 done
9
10 shift $((OPTIND - 1))
11
12 if [[ -n "${deco}" ]]; then
13     case ${deco} in
14         0) decotypes="sgr 0" ;;
15         1) decotypes="bold" ;;
16         4) decotypes="smul" ;;
17         5) decotypes="blink" ;;
18     esac
19 fi
20
21 echo "$([[ -n "${textcolor}" ]] && tput setaf ${textcolor})$([[ -n "${backcolor}" ]] && tput setab ${backcolor})$([[ -n "${decotypes}" ]] && tput ${decotypes})${@}$(tput sgr0)"