-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlitex.sh
executable file
·77 lines (66 loc) · 1.95 KB
/
litex.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# lytex to pdf, with cleaning options
#
# check arg
if [ $# -eq 0 ]; then
echo "usage $0 [-nc|--no-clean -oc|--only-clean -h|--help] <filename>"
exit;
fi
need_compile=true
need_cleaning=true
# check options
while true ; do
case "$1" in
-nc|--no-clean)
need_cleaning=false; shift 1;;
-oc|--only-clean)
need_compile=false; shift 1;;
-h|--help)
echo "usage $0 [-nc|--no-clean -oc|--only-clean -h|--help] <filename>"
exit;;
*)
file=$1;
break;
esac
done
if [ -z ${file} ]; then
echo "Need a filename argument"
echo "usage $0 [-nc|--no-clean -oc|--only-clean -h|--help] <filename>"
exit;
fi
# filename strip of .lytex
obj=${file%.lytex}
# Lets compile to PDF
if [ "$need_compile" = true ]; then
echo "*****************************************************************"
echo "** Compiling to PDF *********************************************"
echo "*****************************************************************"
echo "lilypond-book --format=latex --pdf ${obj}.lytex"
echo "latexmk --pdf ${obj}.tex"
lilypond-book --format=latex --pdf ${obj}.lytex && latexmk -pdf $obj.tex
fi
if [ "$need_cleaning" = true ]; then
echo "*****************************************************************"
echo "** Cleaning *****************************************************"
echo "*****************************************************************"
latexmk -c ${obj}.tex
# then directories
list=`grep "\input{.*/lily.*tex}" ${obj}.tex`
## echo "${list}"
for l in ${list}; do
#echo "ori=${l}"
nostart=${l#\\input\{}
#echo "no=${nostart}"
rep=${nostart%/lily*}
#echo "rep=${rep}"
echo "rm -rf ${rep}"
rm -rf ${rep}
done
echo "rm ${obj}.dep ${obj}.tex"
rm -f ${obj}.dep ${obj}.tex
echo "rm snippet*.ly"
rm -f snippet*.ly
rm -f tmp*.pdf tmp*.out
rm -f lock
fi