aboutsummaryrefslogtreecommitdiffstats
path: root/bin/tex2pdf
blob: a7c367e87bede832f33e45e40370483f08e82946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
logdestination="$HOME/.log/tex2pdf.log"
already_open=$(ps aux | grep "$1.pdf" | grep -v "grep")
rm -rf $logdestination
touch $logdestination
echo "tex2pdf called with $1.tex">>$logdestination
echo "#####################################################">>$logdestination
echo "################## pdflatex, run #1 #################">>$logdestination
echo "#####################################################">>$logdestination
pdflatex -interaction=nonstopmode $1.tex>>$logdestination
echo "bibtex:">>$logdestination
bibtex $1.aux>>$logdestination
echo "#####################################################">>$logdestination
echo "################## pdflatex, run #2 #################">>$logdestination
echo "#####################################################">>$logdestination
pdflatex -interaction=nonstopmode $1.tex>>$logdestination
echo "####### ##############################################">>$logdestination
echo "################## pdflatex, run #3 #################">>$logdestination
echo "#####################################################">>$logdestination
pdflatex -interaction=nonstopmode $1.tex>>$logdestination
echo "#####################################################">>$logdestination
echo "Launching mupdf with $1.pdf.">>$logdestination

if [ -n "$already_open" ]; then
  kill "$(echo $already_open | awk '{print $2}')"
  echo "Killing pid $(echo $already_open | awk '{print $2}'), which has $1.pdf open already." >>$logdestination
fi
mupdf $1.pdf &

echo "#####################################################">>$logdestination
echo "Removing aux,bbl,blg,dvi,lof,log,lot,nav,out,snm,toc.">>$logdestination
echo "Current directory: $(pwd) and children of depth 1.">>$logdestination
rm -f *.{aux,bbl,bcf,blg,dvi,lof,log,lot,nav,out,run.xml,snm,toc,vrb} */*.{aux,bbl,bcf,blg,dvi,lof,log,lot,nav,out,run.xml,snm,toc,vrb}