-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation.sh
executable file
·58 lines (49 loc) · 981 Bytes
/
animation.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
56
57
58
#!/bin/bash
# This file consist animation components
SPINNER=( '|' '/' '-' '\' '|' '\' '-' '/' '|' '/' '-' '\' '|' )
STATUS_SYMBOLS=( "" "" "" "" "" "" "" "" "" "" "" "" )
BLACK='\033[1;30m'
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
PURPLE='\033[1;35m'
CYAN='\033[1;36m'
WHITE='\033[1;37m'
NC='\033[0m'
SUCCESS="${GREEN}[\xe2\x9c\x94]${NC}"
FAILURE="${RED}[\xe2\x9c\x98]${NC}"
ATTENTION="${YELLOW}[!]${NC}"
COLORS=( ${BLACK} ${RED} ${GREEN} ${YELLOW} ${BLUE} ${PURPLE} ${CYAN} ${WHITE} )
function spin() {
while [ 1 ]
do
for COLOR in "${COLORS[@]}"
do
printf ${COLOR}
for CHAR in "${SPINNER[@]}"
do
echo -ne "\r${CHAR}"
/bin/sleep 0.2
done
done
done
}
function dot() {
while [ 1 ]
do
echo -ne "."
/bin/sleep 0.2
done
}
function start_and_stop_animation() {
$1 &
ANIMATION_PID=$!
trap 'kill $ANIMATION_PID' SIGTERM SIGKILL
/bin/sleep $2
kill ${ANIMATION_PID}
if [ $1 = "dot" ]
then
echo ""
fi
}