Patch-ID: bash40-021
[bash.git] / examples / scripts / scrollbar
blob388bea8e137c8429c841fa3c90307a337a739233
1 #!/bin/bash
3 # scrollbar - display scrolling text
5 # usage: scrollbar args
7 # A cute hack originally from Heiner Steven <hs@bintec.de>
9 # converted from ksh syntax to bash v2 syntax by Chet Ramey
11 WIDTH=${COLUMNS:-80}
12 WMINUS=$(( $WIDTH - 1 ))
14 [ $# -lt 1 ] && set -- TESTING
16 # use the bash-2.02 printf builtin
17 Text=$(printf "%-${WIDTH}s" "$*")
18 Text=${Text// /_}
20 while :
22 printf "%-.${WIDTH}s\r" "$Text"
23 LastC=${Text:${WMINUS}:1}
24 Text="$LastC""${Text%?}"
25 done