aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scripts/scrollbar2
diff options
context:
space:
mode:
Diffstat (limited to 'examples/scripts/scrollbar2')
-rwxr-xr-xexamples/scripts/scrollbar224
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/scripts/scrollbar2 b/examples/scripts/scrollbar2
new file mode 100755
index 0000000..0e53634
--- /dev/null
+++ b/examples/scripts/scrollbar2
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# scrollbar - display scrolling text
+#
+# usage: scrollbar args
+#
+# A cute hack originally from Heiner Steven <hs@bintec.de>
+#
+# converted from ksh syntax to bash v2 syntax by Chet Ramey
+
+WIDTH=${COLUMNS:-80}
+WMINUS=$(( $WIDTH - 1 ))
+
+[ $# -lt 1 ] && set -- TESTING
+
+# use the bash-2.02 printf builtin
+Text=$(printf "%-${WIDTH}s" "$*")
+
+while :
+do
+ printf "%-.${WIDTH}s\r" "$Text"
+ LastC=${Text:${WMINUS}:1}
+ Text="$LastC""${Text%?}"
+done