OSDN Git Service

[update] : Added auto rerun
[alterlinux/LUBS.git] / echo_color
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: GPL-3.0
3 #
4 # mk-linux419
5 # Twitter: @fascoder_4
6 # Email  : m.k419sabuaka@gmail.com
7 #
8 # (c) 2019-2020 Fascode Network.
9 #
10 # echo_color
11 #
12
13 while getopts 't:b:d:' arg; do
14     case ${arg} in
15         t) textcolor="${OPTARG}" ;;
16         b) backcolor="${OPTARG}" ;;
17         d) deco="${OPTARG}" ;;
18         *) echo "Invalid argument '${OPTARG}'" ;;
19     esac
20 done
21
22 shift $((OPTIND - 1))
23
24 if [[ -n "${deco}" ]]; then
25     case ${deco} in
26         0) decotypes="sgr 0" ;;
27         1) decotypes="bold" ;;
28         4) decotypes="smul" ;;
29         5) decotypes="blink" ;;
30         *) echo "Invalid argument '${deco}'" ;;
31     esac
32 fi
33
34 echo "$([[ -n "${textcolor}" ]] && tput setaf "${textcolor}")$([[ -n "${backcolor}" ]] && tput setab "${backcolor}")$([[ -n "${decotypes}" ]] && tput "${decotypes}")${*}$(tput sgr0)"