: The top twenty shell. Keeps a .cache of the top twenty commands : The cache maintains an order most likely to represent the frequency of use. : and presents them as a menu to the user N=20 NMINUS1=`expr $N - 1` if [ $# -eq 0 ] then prompt=`hostname`':Select command? ' else echo Usage: $0 ; exit 1 fi for server in blaze iris orion scorpio gemini challenge indigo do xhost $server >/dev/null 2>/dev/null & done echo Input CTRL/D to exit if [ -r $HOME/.cache ] then cat -n $HOME/.cache else cat /dev/null >$HOME/.cache fi echo Input command echo $prompt; # WAS echo $prompt'\c'; while read line do if [ x"$line" = 'x' ] then cat -n $HOME/.cache echo Input a number or any UNIX command else if expr "$line" : '-[0-9][0-9]*' >/dev/null then n=`expr "$line" : '-\([0-9][0-9]*\)'` echo Delete $n sed "$n"d <$HOME/.cache >$HOME/.newcache mv $HOME/.newcache $HOME/.cache else case "$line" in [1-9]) command=`sed -n "$line"'p' $HOME/.cache`;; 1[0-9]) command=`sed -n "$line"'p' $HOME/.cache` ;; 20) command=`sed -n "$line"'p' $HOME/.cache` ;; *) command="$line" esac xterm -e $command & if fgrep -sx "$command" $HOME/.cache then n=`fgrep -xn "$command" $HOME/.cache|sed 's/:.*$//` if [ $n -gt 1 ] then awk <$HOME/.cache >$HOME/.newcache ' NRn{print} ' n=$n command="$command" else cp $HOME/.cache $HOME/.newcache fi else (head -$NMINUS1 $HOME/.cache; echo "$command")>$HOME/.newcache fi mv $HOME/.newcache $HOME/.cache fi fi date cat -n $HOME/.cache echo $prompt; # was echo $prompt'\c'; done