diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-02 14:23:33 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-02 14:23:33 +0100 |
commit | 58a9e65b5554b2c9552540dfea96b562375cf321 (patch) | |
tree | 118dbc0f74d7d09c328e5fbdecd118c7f3f23ee4 /pdfs/toPDF.sh | |
parent | 1ab2d661fb0ffa625d828792deabfb92a5c3611a (diff) | |
download | scripts-58a9e65b5554b2c9552540dfea96b562375cf321.tar.gz scripts-58a9e65b5554b2c9552540dfea96b562375cf321.zip |
Mon 02 Dec 2019 02:23:33 PM CET
Diffstat (limited to 'pdfs/toPDF.sh')
-rwxr-xr-x | pdfs/toPDF.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pdfs/toPDF.sh b/pdfs/toPDF.sh new file mode 100755 index 0000000..e4e6ece --- /dev/null +++ b/pdfs/toPDF.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# toPDF.sh +# +# Usage: toPDF.sh [-o] INPUTFILE +# +# Compiles a file to a temporal PDF using pandoc, updating the temporal file if +# it already exists. +# Opens the file with $READER if -o option is given. + +if [ "$1" = "-o" ]; then + open="1" + shift +fi + +[ -z "$1" ] && exit 1 + +targetDir="/tmp/toPDF" +sourceFile="$1" +targetFile="${targetDir}/${sourceFile##*/}" +targetFile="${targetFile%.*}.pdf" + +[ -d "$targetDir" ] || mkdir -p "$targetDir" +pandoc "$sourceFile" -o "$targetFile" +[ -n "$open" ] && "$READER" "$targetFile" & |