Skip to content

Commit 0142acb

Browse files
authored
Added a rainbow screensaver script
This script displays a colorful rainbow animation in the terminal. It has an option to list the rainbow instead of animating it using the command: rainbow -l.
1 parent 1f34198 commit 0142acb

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

rainbow.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
#Credit to IgnasFalcon for this script
4+
#https://github.com/IgnasFalcon/Rainbow-Shell
5+
#Usage: rainbow [-l] [CYCLES]
6+
7+
clear
8+
9+
#Define list option
10+
list_mode=false
11+
12+
while getopts "l" opt; do
13+
case "$opt" in
14+
l) list_mode=true ;;
15+
*) exit 1 ;;
16+
esac
17+
done
18+
19+
#This removes the -l
20+
shift $((OPTIND - 1))
21+
22+
#Define colors
23+
colors=(
24+
"\e[31m"
25+
"\e[38;5;208m"
26+
"\e[33m" # Replacement for yellow
27+
"\e[32m"
28+
"\e[36m"
29+
"\e[34m" # Closest to indigo
30+
"\e[35m"
31+
)
32+
33+
#Rainbow function
34+
rainbow() {
35+
for c in "${colors[@]}"; do
36+
if ! $list_mode; then
37+
clear
38+
fi
39+
echo -e "${c}$(echo "
40+
ooooooooo. .o. ooooo ooooo ooo oooooooooo. .oooooo. oooooo oooooo oooo
41+
.888 .Y88. .888. .888. .888b. .8. .888. .Y8b d8P. .Y8b .888. .888. .8.
42+
888 .d88. .88888. 888 8 .88b. 8 888 888 888 888 .888. .8888. .8.
43+
888ooo88P. .8. .888. 888 8 .88b. 8 888oooo888. 888 888 .888 .8..888. .8.
44+
888.88b. .88ooo8888. 888 8 .88b.8 888 .88b 888 888 .888.8. .888.8.
45+
888 .88b. .8. .888. 888 8 .888 888 .88P .88b d88. .888. .888.
46+
o888o o888o o88o o8888o o888o o8o .8 o888bood8P. .Y8bood8P. .8. .8.")\e[0m\r"
47+
sleep 1
48+
done
49+
}
50+
51+
#Display rainbow
52+
index=$(( $1 + 0 ))
53+
if [[ $1 > "" ]]; then
54+
while [[ $index > 0 ]]; do
55+
rainbow
56+
(( index-- ))
57+
done
58+
else
59+
while true; do
60+
rainbow
61+
(( index-- ))
62+
done
63+
fi

0 commit comments

Comments
 (0)