forked from Silejonu/bash_loading_animations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_loading_animations.demo
executable file
·74 lines (67 loc) · 2.82 KB
/
bash_loading_animations.demo
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
#!/usr/bin/env bash
# shellcheck disable=SC2034 # https://github.com/koalaman/shellcheck/wiki/SC2034
# Load in the functions and animations
source ./bash_loading_animations.sh
# Run BLA::stop_loading_animation if the script is interrupted
trap BLA::stop_loading_animation SIGINT
demo_loading_animation() {
BLA_active_loading_animation=( "${@}" )
# Extract the delay between each frame from the active_loading_animation array
BLA_loading_animation_frame_interval="${BLA_active_loading_animation[0]}"
# Sleep long enough that all frames are showed
# substract 1 to the number of frames to account for index [0]
demo_duration=$( echo "${BLA_active_loading_animation[0]} * ( ${#BLA_active_loading_animation[@]} - 1 )" | bc )
# Make sure each animation is shown for at least 3 seconds
if [[ $( echo "if (${demo_duration} < 3) 0 else 1" | bc ) -eq 0 ]] ; then
demo_duration=3
fi
unset "BLA_active_loading_animation[0]"
echo
BLA::play_loading_animation_loop &
BLA_loading_animation_pid="${!}"
sleep "${demo_duration}"
kill "${BLA_loading_animation_pid}" &> /dev/null
clear
}
tput civis # Hide the terminal cursor
clear
demo_loading_animation "${BLA_classic[@]}"
demo_loading_animation "${BLA_box[@]}"
demo_loading_animation "${BLA_bubble[@]}"
demo_loading_animation "${BLA_breathe[@]}"
demo_loading_animation "${BLA_growing_dots[@]}"
demo_loading_animation "${BLA_passing_dots[@]}"
demo_loading_animation "${BLA_metro[@]}"
demo_loading_animation "${BLA_snake[@]}"
demo_loading_animation "${BLA_filling_bar[@]}"
demo_loading_animation "${BLA_classic_utf8[@]}"
demo_loading_animation "${BLA_bounce[@]}"
demo_loading_animation "${BLA_vertical_block[@]}"
demo_loading_animation "${BLA_horizontal_block[@]}"
demo_loading_animation "${BLA_quarter[@]}"
demo_loading_animation "${BLA_triangle[@]}"
demo_loading_animation "${BLA_semi_circle[@]}"
demo_loading_animation "${BLA_rotating_eyes[@]}"
demo_loading_animation "${BLA_firework[@]}"
demo_loading_animation "${BLA_braille[@]}"
demo_loading_animation "${BLA_braille_whitespace[@]}"
demo_loading_animation "${BLA_trigram[@]}"
demo_loading_animation "${BLA_arrow[@]}"
demo_loading_animation "${BLA_bouncing_ball[@]}"
demo_loading_animation "${BLA_big_dot[@]}"
demo_loading_animation "${BLA_modern_metro[@]}"
demo_loading_animation "${BLA_pong[@]}"
demo_loading_animation "${BLA_earth[@]}"
demo_loading_animation "${BLA_clock[@]}"
demo_loading_animation "${BLA_moon[@]}"
demo_loading_animation "${BLA_orange_pulse[@]}"
demo_loading_animation "${BLA_blue_pulse[@]}"
demo_loading_animation "${BLA_football[@]}"
demo_loading_animation "${BLA_blink[@]}"
demo_loading_animation "${BLA_camera[@]}"
demo_loading_animation "${BLA_sparkling_camera[@]}"
demo_loading_animation "${BLA_sick[@]}"
demo_loading_animation "${BLA_monkey[@]}"
demo_loading_animation "${BLA_bomb[@]}"
tput cnorm # Restore the terminal cursor
exit 0