Created
June 1, 2014 14:41
-
-
Save babarot/9192f75fe246cbba9139 to your computer and use it in GitHub Desktop.
Progress...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ECHO="echo -e" | |
case `$ECHO` in | |
-e) | |
ECHO=echo;; | |
esac | |
print_bar() | |
{ | |
percent=$1 | |
column=`expr 71 \* "$percent" / 100` | |
nspace=`expr 71 - "$column"` | |
bar='\r[' | |
set dummy | |
while [ $# -le "$column" ] | |
do | |
bar=$bar'=' | |
set - "$@" dummy | |
done | |
bar=$bar'>' | |
set dummy | |
while [ $# -le "$nspace" ] | |
do | |
bar=$bar' ' | |
set - "$@" dummy | |
done | |
bar=$bar'] '$percent'%\c' | |
$ECHO "$bar" | |
} | |
i=0 | |
while [ "$i" -le 100 ] | |
do | |
print_bar "$i" | |
i=`expr "$i" + 1` | |
sleep 1 | |
done | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for ((current_count=0; ; current_count++)); do | |
let type=current_count%4 | |
case "$type" in | |
0) echo -ne "|\033[1D";; | |
1) echo -ne "\\\\\033[1D";; | |
2) echo -ne "-\033[1D";; | |
3) echo -ne "/\033[1D";; | |
esac | |
sleep 0.01s | |
done & | |
if sleep 3; then | |
kill -9 $! | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function progress-rotate-animation(){ | |
local start_count=$1 | |
local end_count=$2 | |
if [ $# -eq 3 ]; then | |
local interval_second=$3 | |
fi | |
for ((current_count=start_count;current_count<end_count;current_count++)); | |
do | |
let type=current_count%4 | |
case $type in | |
0) echo -ne "|\033[1D";; | |
1) echo -ne "/\033[1D";; | |
2) echo -ne "-\033[1D";; | |
3) echo -ne "\\\\\033[1D";; | |
esac | |
if [ $interval_second ]; then | |
sleep $interval_second | |
fi | |
done | |
} | |
progress-rotate-animation 0 100 0.01s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment