#! /bin/sh


# You only have to make sure that your bibfiles are copied from the
# correct spot in this file they are copied from /home/mase

FILE=thesis.tex
COMMAND="T"


until [ "$COMMAND" = "x" ]
do
    echo -n "process :> "
    read COMMAND OPTION
     
    case $COMMAND in
    h) echo "m   make all"
       echo "f   latex"
       echo "v   gv thesis.ps"
       echo "p   make postscript"
       echo "p2  make postscript, 2 pages on 1"
       echo "c   make clean"
       echo "fb  bibtex thesis"
       echo "b   prepare the bibtex file"
       echo "pdf make pdf from ps file and view it"
       echo "s   show xdvi"
       echo "vb  view bibtex errors in vi"
       echo "vl  view latex log file"
       echo "vr  view reference and label errors"
       echo "fp  latex and make postscript"
       echo "ffp latex, latex and make postscript"
       echo "q   print all printer queues";;
    q) echo "--------------GRIJS---------"
       lpq -Pgrijs
       echo "--------------WIT-----------"
       lpq -Pwit
       echo "--------------KLEUR---------"
       lpq -Pkleur
       echo "--------------DUPLEX--------"
       lpq -Pduplex
       echo "--------------SLIDE---------"
       lpq -Pslide;;
    ffp) latex thesis.tex
        latex thesis.tex
        dvips -o thesis.ps thesis.dvi;;
    vr) grep Reference thesis.log > reflab.log
        grep Label thesis.log >> reflab.log
        vi reflab.log;;
    fp) latex thesis.tex
	dvips -o thesis.ps thesis.dvi;;
    s) kdvi thesis.dvi &;;
    fb) bibtex thesis ;;
    pdf) ps2pdf thesis.ps thesis.pdf
         acroread thesis.pdf & ;;
    b) cd bib/
       rm -f thesis.bib thesis3.bib thesis2.bib
       rm -f TOTAL.bib
       cp /home/mase/rbib/bib-files/TOTAL.bib .
       cp /home/mase/rbib/bib-files/Book.bib .
       cp /home/mase/rbib/bib-files/longstrings.bib .
       bibtool -s TOTAL.bib Book.bib longstrings.bib > thesis2.bib
       bibtool -d ./thesis2.bib > thesis3.bib
       ../bibclean -no-fix-names thesis3.bib > thesis.bib
       rm -f thesis3.bib
       rm -f thesis2.bib
       cd .. ;;
    m) make all;;
    p) dvips -o thesis.ps thesis.dvi;;
    p2) dvips -o thesis.ps thesis.dvi
        psnup -2 thesis.ps > thesis2.ps
        mv thesis2.ps thesis.ps;;
    f) latex thesis.tex;;
    v) ggv thesis.ps &;;
    vb) vi thesis.blg;;
    vl) vi thesis.log;;
    c) make clean
       make clall
       rm -f reflab.log
       rm -f *~
       rm -f #*
       cd varia
       rm -f *~
       rm -f *.flc
       rm -f #*
       cd ..
       cd part_1
       rm -f *~
       rm -f *.flc
       rm -f #*
       cd ../part_2
       rm -f *~
       rm -f *.flc
       rm -f #*
       cd ../part_3
       rm -f *~
       rm -f *.flc
       rm -f #*
       cd ..;;    
    esac
done
