Skip to content

Instantly share code, notes, and snippets.

@sway
Created July 15, 2012 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sway/3113997 to your computer and use it in GitHub Desktop.
Save sway/3113997 to your computer and use it in GitHub Desktop.
TeXShop + Growl Notifications
#!/bin/bash
IMAGE_RUN="" # Complete path to the desired icon
MSG_RUN="Compilation running"
IMAGE_FAIL=""
MSG_FAIL="Compilation failed"
IMAGE_OK=""
MSG_OK="Compilation done"
BANNER="XeLaTeX"
IDENT="texshopcompile-$1"
DATE="[`date +%H:%M`] $1:"
BASENAME=`basename $1 .tex`
path=$path:/usr/texbin:/usr/local/bin
growlnotify -s -d $IDENT --image "$IMAGE_RUN" -m "${DATE}"$'\n'"${MSG_RUN}" $BANNER
xelatex -halt-on-error -file-line-error -synctex=1 "$1"
if [[ $? -gt 0 ]]; then
growlnotify -d $IDENT -s --image "$IMAGE_FAIL" -m "${DATE}"$'\n'"${MSG_FAIL}" $BANNER
else
PAGES=`cat ${BASENAME}.log | grep "Output written" | grep -o -E "\([^\)]*\)"`
growlnotify -d $IDENT -s --image "$IMAGE_OK" -m "${DATE}"$'\n'"${MSG_OK}"$'\n'"$PAGES" $BANNER
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment