blob: 87e2c34b143ee5ac4ee216a44484850e38677bf8 (
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
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
|
#!/bin/bash
# Create a letter
# Configuration
template=~/documents/letter_template.tex
dir=~/documents/`date +%Y`
texdir=$dir/tex
editor=/usr/bin/vim
reader=/usr/bin/mupdf
function mkpdf () {
pdflatex -shell-escape $1.tex
EXT=(aux log)
for i in ${EXT[*]}
do
rm -v $1.$i
done
}
# Preparation
mkdir -p $dir
mkdir -p $texdir
named=0
while [ $named -eq 0 ]
do
read -p "Enter document name: " REPLY
docname=`echo $REPLY | sed 's/\ /_/g'`
docdate="`date +%Y-%m-%d`"
doc=$dir/${docdate}_${docname}
tex=$dir/${docdate}_${docname}.tex
pdf=$dir/${docdate}_${docname}.pdf
if [ -e $pdf ]
then
read -p "Document already exists. Overwrite? (y/N) " REPLY
[ "$REPLY" == "y" ] || continue
fi
read -p "Create document \"$pdf\"? (Y/n) " REPLY
[ "$REPLY" == "y" -o x"$REPLY" == x ] && named=1
done
cd $dir
cp $template $tex
$editor $tex
mkpdf $doc
$reader $pdf
finished=0
while [ $finished -eq 0 ]
do
read -p "Finished editing? (Y/n) " REPLY
if [ "$REPLY" == "y" -o x"$REPLY" == x ]
then
finished=1
else
$editor $tex
mkpdf $doc
$reader $pdf
fi
done
read -p "Keep a copy of the .tex file? (Y/n) " REPLY
if [ "$REPLY" == "y" -o x"$REPLY" == x ]
then
mv $tex $texdir
else
rm $tex
fi
|