-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlsd-sim
More file actions
executable file
·94 lines (72 loc) · 1.34 KB
/
Copy pathlsd-sim
File metadata and controls
executable file
·94 lines (72 loc) · 1.34 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Global Variables
# Setting rows and width equal to the terminal size.
# Decrementing $rows, as more number of rows cause the screen to scroll. Which we don't want.
rows=$(tput lines);
rows=$rows-2;
width=$(tput cols);
widthOffset=0;
cringe=false;
# Initial clear
printf "\033c"
# Take the user parameters.
while test $# -gt 0; do
case "$1" in
-d | --dry-run)
echo $rows;
exit;
shift;
;;
-r | --rows)
shift
rows=$1
shift
;;
-w | --width)
shift
width=$1
shift
;;
-o | --offset)
shift
widthOffset=$1
shift
;;
-c | --cringe)
shift
cringe=true;
;;
*)
echo "$1 is not a recognized flag!"
exit 1;
;;
esac
done
# Clear screen first
printf "\033c";
# An infinite loop.
for((j=1; j<3;)); do
for((row=0; row<rows; row++)) do
for((k=0; k<widthOffset; k++)); do
printf " ";
done
if ! $cringe ; then
i=$((16 + RANDOM/256))
fi
for((k=0; k<width; k++)); do
# Add some cringe.
if $cringe ; then
i=$((16 + RANDOM/256))
fi
# Do the magic
printf "\e[48;5;%sm " "$i";
printf '\e[0m';
[ ! $(((${i} - 15) % 6)) -eq 0 ] && printf '';
done
printf '\n';
done
# Delay to print the colours.
sleep .001;
# Resets the cursor to (1, 1). Much better than deleting the previous lines or clearing the screen.
printf "\033[1;1H"
done