Skip to content

Instantly share code, notes, and snippets.

@GongT

GongT/ranbow.sh

Created Sep 16, 2019
Embed
What would you like to do?
ranbow animation in bash
#!/bin/bash
RAINBOW=(196 202 208 214 220 226 190 154 118 82 46 46 47 48 49 50 51 45 39 33 27 21 21 57 93 129 165 201 200 199 198 197 196)
function char_rainbow() {
local STR="$1" I
J=$(( $J % ${#RAINBOW[@]} ))
for I in $(seq 0 $(( ${#STR} - 1 )) ) ; do
printf "\e[38;5;%dm%c" "${RAINBOW[J]}" "${STR:${I}:1}"
J=$(( $J + 1 ))
if [[ $J -eq ${#RAINBOW[@]} ]]; then
J=0
fi
done
printf "\e[0m\e[K\n"
}
function frame() {
local J JJ=$1 NN=$2
J=$(( $JJ + $NN * 1 ))
char_rainbow ' _ _ ______ _ _ ____ __ ______ _____ _ _____ '
J=$(( $JJ + $NN * 2 ))
char_rainbow '| | | | ____| | | | / __ \ \ \ / / __ \| __ \| | | __ \ '
J=$(( $JJ + $NN * 3 ))
char_rainbow '| |__| | |__ | | | | | | | | \ \ /\ / / | | | |__) | | | | | |'
J=$(( $JJ + $NN * 4 ))
char_rainbow '| __ | __| | | | | | | | | \ \/ \/ /| | | | _ /| | | | | |'
J=$(( $JJ + $NN * 5 ))
char_rainbow '| | | | |____| |____| |___| |__| | \ /\ / | |__| | | \ \| |____| |__| |'
J=$(( $JJ + $NN * 6 ))
char_rainbow '|_| |_|______|______|______\____/ \/ \/ \____/|_| \_\______|_____/ '
}
for L in $(seq 0 10); do
for I in $(seq 0 3 $(( ${#RAINBOW[@]} - 1 )) ) ; do
echo -ne "\e[s"
echo -ne "\e[1000A\r"
frame $I 2
echo -ne "\e[u"
sleep 0.1
done
done
@GongT

This comment has been minimized.

Copy link
Owner Author

@GongT GongT commented Sep 16, 2019

xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment