home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- ### dirtop - put 'ls' listing in non-scrolling area at top of VTxxx screen.
- ### Usage: dirtop [-c]
- # Only for VTxxx terminals and compatibles, sigh.
-
- ls="/bin/ls -FC" # ls command to use
- maxlines=10 # if more lines in listing than this, quit
-
- # UNCOMMENT THE LINE FOR YOUR SYSTEM:
- #cmd=echo c='\c' e='\033' n= # SysV
- cmd=/usr/5bin/echo c='\c' e='\033' n= # SunOS
- #cmd=/bin/echo c= e="`echo e | tr e '\033'`" n=-n # BSD
-
- case "$1" in
- -c) $cmd $n "${e}[r${e}[2J${c}"; exit 0;; # just reset screen
- "") ;;
- *) echo "Usage: `basename $0` [-c]" 1>&2; exit 1 ;;
- esac
-
- temp=/tmp/DIRTOP$$
- trap 'rm -f $temp; exit' 0 1 2 15
-
- $ls > $temp
- # set number of lines to clear: one more than length of ls listing:
- lines=`expr 1 + \`wc -l < $temp\``
- if [ $lines -gt $maxlines ]
- then
- echo "`basename $0`: Directory listing > $maxlines lines" 1>&2
- exit 1
- else
- # CLEAR SCREEN. SET NO-SCROLL AREA:
- $cmd $n "${e}[2J${c}"
- $cmd $n "${e}[${lines};24r${c}"
- # MOVE CURSOR TO TOP-LEFT CORNER, THEN PRINT LISTING:
- $cmd $n "${e}[0;0f${c}"
- cat $temp
- exit
- fi
-