Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (52 sloc) 1.48 KB
#!/bin/sh
# ----------
# pdl
# Donald L. Merand
# ----------
# run xelatex on a list of files, delete the logs and auxes,
# and open the resulting PDF file. Usable in a pipe.
#
# set the PDF environment variable to change the resulting
# PDF filename
# ----------
# I often use this file in conjunction with pandoc, eg:
# `pandoc <file.md> -f markdown -t latex | pdl` ,
# which will convert a Markdown file to LaTeX, and then generate
# a nice PDF.
# ----------
# set PDF env variable if it's not already set.
[ -z "$PDF" ] && PDF="pdl_result.pdf"
#if we were passed parameters
if [ "$#" -gt 0 ]
then
# for every file passed
for file in "$@"
do
# (if it's an actual file)
if [ -f "$file" ]
then
#run pdflatex on the input, redirect STDOUT to null
xelatex "$file" 1> /dev/null 2> /dev/null
#get the name of the file minus the extension
base_file=${file%.*} #delete the final extension
#now trash the pdflatex files
rm "$base_file".aux "$base_file".log "$base_file".out
#then open the PDF file
open "$base_file".pdf
fi
done
else
#assume STDIN
xelatex 1> /dev/null 2> /dev/null
#creates a file called texput.pdf
#if the syntax was correct and a file was generated...
if [ -f texput.pdf ]
then
#we're re-directing STDERR here because we don't care
# if any of these files are missing
rm texput.aux texput.log texput.out 2> /dev/null
#now open the resulting PDF
mv texput.pdf "$PDF"
open "$PDF"
fi
fi