aboutsummaryrefslogtreecommitdiffstats
path: root/bin/letter
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
committerDavid Runge <david.runge@frqrec.com>2013-11-03 12:30:45 +0100
commit67b0ec5741d327d27afe88783d85fcf2c4c4f204 (patch)
tree4ea47807c5e775927b96eb79933c09fbfcd0468e /bin/letter
downloaddotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.gz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.bz2
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.tar.xz
dotfiles-67b0ec5741d327d27afe88783d85fcf2c4c4f204.zip
First commit
Diffstat (limited to 'bin/letter')
-rw-r--r--bin/letter71
1 files changed, 71 insertions, 0 deletions
diff --git a/bin/letter b/bin/letter
new file mode 100644
index 0000000..87e2c34
--- /dev/null
+++ b/bin/letter
@@ -0,0 +1,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
+