diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-25 13:22:28 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-25 13:22:28 +0200 |
commit | 6f9314220c737ea91fd728c35f0a75b500ad1889 (patch) | |
tree | 828ec2e35ec411de629870190f4e3b387dc5dce2 /etc | |
parent | 9c74d820cb794afc41fd3361266c22a6062c72d2 (diff) |
New function: progress (for internal use)
Diffstat (limited to 'etc')
-rw-r--r-- | etc/functions/progress | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/etc/functions/progress b/etc/functions/progress new file mode 100644 index 0000000..0d0292d --- /dev/null +++ b/etc/functions/progress @@ -0,0 +1,25 @@ +## vim:ft=zsh +## progress - draw a simple progress bar +## Written 2008 by Daniel Friesel <derf@derf.homelinux.org> + +typeset -i current=$1 +typeset -i max=$2 +typeset desc=$3 +typeset desc2=$4 +typeset output='' +typeset currentper=$(( (current*100)/max )) +typeset c a +function item { + typeset j + for j in {0..$1}; { + (( j > 0 )) && output+=$2 + } +} +c=$(( currentper/5 )) +a=$(( 20-c )) +output+="$desc [" +item $c '=' +item $a ' ' +output+="] $currentper% $desc2" +echo -ne "\r \r" +echo -ne $output |