Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

windows: just like the OS

  • Loading branch information...
commit e794325865fff524d7bd37af3c49bd2bbd7d7b7b 1 parent dc9ed00
Dave Reisner authored April 10, 2011

Showing 1 changed file with 36 additions and 0 deletions. Show diff stats Hide diff stats

  1. 36  windows
36  windows
... ...
@@ -0,0 +1,36 @@
  1
+#!/bin/bash
  2
+
  3
+#
  4
+# a useless progress bar, windows style. doesn't tell you anything except that
  5
+# this particular process hasn't (yet) crashed.
  6
+#
  7
+
  8
+declare bc1='-'            # "filled" progress
  9
+declare bc2='-'            # "unfilled" progress
  10
+declare pulser='<│││>'     # windows is awesome
  11
+declare -i bw=40           # bar width
  12
+declare -i pw=${#pulser}   # pulser width
  13
+st='.02s'                  # sleep time
  14
+
  15
+printbar() {
  16
+  # leading visible bar
  17
+  printf '\e[1;35m%*s\e[0m' "$1" | tr ' ' "$bc1"
  18
+
  19
+  # pulser
  20
+  printf '\e[1;34m%s\e[0m' "$pulser"
  21
+
  22
+  # trailing visible bar
  23
+  printf '\e[1;35m%*s\e[0m\r' "$(( bw - pw - $1 ))" | tr ' ' "$bc2"
  24
+
  25
+  sleep $st
  26
+}
  27
+
  28
+while true; do
  29
+  for (( i = 0; i < bw-pw; i++ )); do
  30
+    printbar $i
  31
+  done
  32
+  for (( i = bw-pw; i > 0; i--)); do
  33
+    printbar $i
  34
+  done
  35
+done
  36
+

0 notes on commit e794325

Please sign in to comment.
Something went wrong with that request. Please try again.