-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_spinner1
More file actions
executable file
·66 lines (56 loc) · 1.47 KB
/
x_spinner1
File metadata and controls
executable file
·66 lines (56 loc) · 1.47 KB
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
59
60
61
62
63
64
65
66
#!/bin/bash
# **************************************************************************** #
# #
# ::: :::::::: #
# x_spinner1 :+: :+: :+: #
# +:+ +:+ +:+ #
# By: xvan-ham <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/11/05 19:50:25 by xvan-ham #+# #+# #
# Updated: 2020/11/05 19:50:25 by xvan-ham ### ########.fr #
# #
# **************************************************************************** #
function watch() {
while :; do clear; your_command; sleep 2; done
}
function cycle() {
t=0
t2=$1
str="Please wait: "
p=0
cps=$(($2-1))
while [ $t2 -gt 0 ]
do
echo -ne "\r\033[K${str}${t2} seconds "
if [ $t -eq 0 ]
then
echo -ne " |"
fi
if [ $t -eq 1 ]
then
echo -ne " /"
fi
if [ $t -eq 2 ]
then
echo -ne " -"
fi
if [ $t -eq 3 ]
then
echo -ne " \\"
fi
(( t++ ))
if [ $t -ge 4 ]
then
t=0
fi
if [ $p -lt $cps ]
then
(( p++ ))
else
(( t2-- ))
p=0
fi
sleep $(echo "scale=3; (1/($cps+1))" | bc)
done
}
cycle "10" "6"