-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashbounce.sh
More file actions
executable file
·48 lines (42 loc) · 973 Bytes
/
bashbounce.sh
File metadata and controls
executable file
·48 lines (42 loc) · 973 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
#!/bin/bash
# updated the comment
trap ctrl_c INT
trap update_size WINCH
function mssleep() {
pms=`date +%s%N | cut -c1-13`
stop=$((pms+mssleep))
while [ $pms -le $stop ]
do
pms=`date +%s%N | cut -c1-13`
done
}
function update_size() {
maxx=$((`stty size | awk '{print $2}'` - 1))
maxy=$((`stty size | awk '{print $1}'` - 2))
clear
}
function ctrl_c() {
exitnow="Y"
pms=$stop
}
mssleep=100 && [ ! -z $2 ] && mssleep=$2
exitnow="N"
C="O" && [ ! -z $1 ] && C=$1
x=0 && y=0
dx=1 && dy=1
tput civis
update_size
while [ $exitnow == "N" ]
do
tput cup $y $x && echo " "
x=$((x+dx))
y=$((y+dy))
tput cup $y $x && echo "$C"
[ $x -ge $maxx -o $x -le 0 ] && dx=$((-1*dx))
[ $y -ge $maxy -o $y -le 0 ] && dy=$((-1*dy))
[ $x -ge $maxx ] && x=$maxx
[ $y -ge $maxy ] && y=$maxy
mssleep
done
tput cvvis
clear