-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathecho_color
More file actions
executable file
·34 lines (30 loc) · 840 Bytes
/
Copy pathecho_color
File metadata and controls
executable file
·34 lines (30 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0
#
# mk-linux419
# Twitter: @fascoder_4
# Email : m.k419sabuaka@gmail.com
#
# (c) 2019-2020 Fascode Network.
#
# echo_color
#
while getopts 't:b:d:' arg; do
case ${arg} in
t) textcolor="${OPTARG}" ;;
b) backcolor="${OPTARG}" ;;
d) deco="${OPTARG}" ;;
*) echo "Invalid argument '${OPTARG}'" ;;
esac
done
shift $((OPTIND - 1))
if [[ -n "${deco}" ]]; then
case ${deco} in
0) decotypes="sgr 0" ;;
1) decotypes="bold" ;;
4) decotypes="smul" ;;
5) decotypes="blink" ;;
*) echo "Invalid argument '${deco}'" ;;
esac
fi
echo "$([[ -n "${textcolor}" ]] && tput setaf "${textcolor}")$([[ -n "${backcolor}" ]] && tput setab "${backcolor}")$([[ -n "${decotypes}" ]] && tput "${decotypes}")${*}$(tput sgr0)"