]> code.delx.au - monosys/blob - scripts/osx_preview
Fixed so it sends referer and cookies
[monosys] / scripts / osx_preview
1 #!/bin/bash
2 # $ pdflatex somefile.tex && preview.sh somefile.pdf
3 # Preview.app will close the file and reopen it
4 # You must run this command first to update your Preview.app bundle to support
5 # basic AppleScript
6 # $ defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool YES
7
8 filename="${1}"
9 if [ ! -r "${filename}" ]; then
10 echo "Error, could not read ${filename}"
11 exit 1
12 fi
13
14 osascript <<EOF
15 tell application "Preview"
16 repeat with theWindow in windows
17 if name of theWindow starts with "$(basename "${filename}")" then
18 close theWindow
19 end if
20 end repeat
21 end tell
22 EOF
23
24 open "${filename}"
25