i-bash/examples/scripts/scrollbar

26 lines
470 B
Text
Raw Normal View History

1996-12-23 17:02:34 +00:00
#!/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}
1998-04-17 19:52:44 +00:00
WMINUS=$(( $WIDTH - 1 ))
1996-12-23 17:02:34 +00:00
[ $# -lt 1 ] && set -- TESTING
1998-04-17 19:52:44 +00:00
# use the bash-2.02 printf builtin
1996-12-23 17:02:34 +00:00
Text=$(printf "%-${WIDTH}s" "$*")
1998-04-17 19:52:44 +00:00
Text=${Text// /_}
1996-12-23 17:02:34 +00:00
while :
do
printf "%-.${WIDTH}s\r" "$Text"
1998-04-17 19:52:44 +00:00
LastC=${Text:${WMINUS}:1}
Text="$LastC""${Text%?}"
1996-12-23 17:02:34 +00:00
done