#!/bin/bash # $ pdflatex somefile.tex && preview.sh somefile.pdf # Preview.app will close the file and reopen it # You must run this command first to update your Preview.app bundle to support # basic AppleScript # $ defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool YES filename="${1}" if [ ! -r "${filename}" ]; then echo "Error, could not read ${filename}" exit 1 fi osascript <