forked from pollev/bash_progress_bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_advanced.sh
executable file
·42 lines (37 loc) · 1.16 KB
/
test_advanced.sh
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
#!/bin/bash
# Source progress bar
source ./progress_bar.sh
generate_some_output_and_sleep() {
echo "Here is some output"
head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9~!@#$%^&*_-'
head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9~!@#$%^&*_-'
head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9~!@#$%^&*_-'
head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9~!@#$%^&*_-'
echo -e "\n\n------------------------------------------------------------------"
echo -e "\n\n Now sleeping briefly \n\n"
sleep 0.3
}
MAX=99
[ -n "$1" ] && MAX=$1
main() {
# Make sure that the progress bar is cleaned up when user presses ctrl+c
enable_trapping
# Enable ETA
ETA_ENABLED="true"
# Create progress bar
setup_scroll_area "Processing" "$MAX"
# Compute middle for user input test
((MIDDLE = MAX / 2))
for i in $(seq 1 "$MAX"); do
if [ "$i" -eq $MIDDLE ]; then
echo "waiting for user input"
block_progress_bar "$i"
read -r -p "User input: "
else
generate_some_output_and_sleep
draw_progress_bar "$i" "$(date "+%r")| $i on $MAX"
fi
done
destroy_scroll_area
}
main