-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoffee.sh
More file actions
53 lines (48 loc) · 736 Bytes
/
Copy pathcoffee.sh
File metadata and controls
53 lines (48 loc) · 736 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
IMGS=(
"
( ( \n\
) ) \n\
.......... \n\
| |]\n\
\ / \n\
-------- \n
" "
) ) \n\
( ( \n\
.......... \n\
| |]\n\
\ / \n\
-------- \n
" )
function tput_loop() {
x=0
while [ $x -lt 8 ]; do
tput $1
x=$(( x + 1 ))
done
}
function coffee() {
IFS='%'
tput civis
while [ "$(ps a | awk '{print $1}' | grep $1)" ]
do
for x in "${IMGS[@]}"
do
echo -ne $x
tput_loop "cuu1"
sleep 0.5
done
done
tput_loop "cud1"
tput cvvis
}
function initial() {
if [[ "$1" =~ ^sleep\ [0-9]+$ ]]; then
$1 & coffee $!
else
echo 'Usage: ./coffee "sleep 10"'
exit 1
fi
}
initial "$1"