-
Notifications
You must be signed in to change notification settings - Fork 19
/
box.sh
55 lines (55 loc) · 1.16 KB
/
box.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function box()
{
blue=1
green=2
cyan=3
red=4
purple=5
yellow=6
gray=7
light_blue=8
light_green=9
light_cyan=10
light_red=11
light_purple=12
light_yellow=13
light_gray=14
color[blue]=34
color[green]=32
color[cyan]=36
color[red]=31
color[purple]=35
color[yellow]=33
color[gray]=37
color[light_blue]=34
color[light_green]=32
color[light_cyan]=36
color[light_red]=31
color[light_purple]=35
color[light_yellow]=33
color[light_gray]=30
local codef=0
local codet=0
local str=("$1")
local cot=("$2")
local cof=("$3")
local len=${#str}
local cul='┌'
local cur='┐'
local cbl='└'
local cbr='┘'
local ver='│'
if [[ $cof == light* ]] ;
then
codef=1
fi
if [[ $cot == light* ]] ;
then
codet=1
fi
printf -v line '%*s' "$((len+2))"
printf -v line '%s' "${line// /─}"
echo -en "\033[${codef};${color[${cof}]}m$cul$line$cur\033[m\n"
echo -en "\033[${codef};${color[${cof}]}m$ver\033[${codet};${color[${cot}]}m $str \033[m\033[${codef};${color[${cof}]}m$ver\n"
echo -en "\033[${codef};${color[${cof}]}m$cbl$line$cbr\033[m\n"
}