On Mac OS X use the open command and the OS will use the correct viewer chosen by the user
open "$pdffile"
On Feb 16, 2012, at 12:34 AM, Matthieu Moy wrote:
quoted hunk ↗ jump to hunk
Tim Haga [off-list ref] writes:
quoted
While testing your script on my office machine i discovered that the
following might be a problem:
quoted
+if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
+ xpdf "$pdffile"
+fi
Xpdf is not installed on all machines (e.g. it's not installed on my
office machine), so maybe it would be a good idea to use a environment
variable instead?
Right. I'm squashing this into the next version to allow configuration
(environment variable or --pdf-viewer) and sensible auto-detection:
diff --git a/contrib/latex/git-latexdiff b/contrib/latex/git-latexdiff
index 13aeb9a..85aafda 100755
--- a/contrib/latex/git-latexdiff
+++ b/contrib/latex/git-latexdiff
@@ -20,6 +20,8 @@ Options:
--no-view Don't display the resulting PDF file
--view View the resulting PDF file
(default if -o is not used)
+ --pdf-viewer CMD
+ Use CMD to view the PDF file (default: \$PDFVIEWER)
--no-cleanup Don't cleanup temp dir after running
-o FILE, --output FILE
Copy resulting PDF into FILE
@@ -46,7 +48,7 @@ verbose_progress () {
verbose_done () {
if [ "$verbose" = 1 ]; then
- echo " done."
+ echo " ${1:-done}."
fi
}
@@ -75,6 +77,10 @@ while test $# -ne 0; do
"--view")
view=1
;;
+ "--pdf-viewer")
+ shift
+ PDFVIEWER="$1"
+ ;;
"--no-cleanup")
cleanup=0
;;
@@ -114,6 +120,28 @@ if [ "$old" = "" ]; then
exit 1fi
+verbose "Auto-detecting PDF viewer"
+for command in xdg-open evince okular xpdf acroread; do
+ if [ "$PDFVIEWER" = "" ]; then
+ if command -v "$command" >/dev/null 2>&1; then
+ PDFVIEWER="$command"
+ else
+ verbose_progress
+ fi
+ fi
+done
+verbose_done "$PDFVIEWER"
+
+case "$view" in
+ maybe|1)
+ if [ "$PDFVIEWER" = "" ]; then
+ echo "warning: could not find a PDF viewer on your system."
+ echo "warning: Please set \$PDFVIEWER or use --pdf-viewer CMD."
+ PDFVIEWER=false
+ fi
+ ;;
+esac
+
if [ "$main" = "" ]; then
printf "%s" "No --main provided, trying to guess ... "
main=$(git grep -l '^[ \t]*\\documentclass')@@ -212,7 +240,7 @@ if [ "$output" != "" ]; then
fi
if [ "$view" = 1 ] || [ "$view" = maybe ] && [ "$output" = "" ]; then
- xpdf "$pdffile"
+ "$PDFVIEWER" "$pdffile"
fi
if [ "$cleanup" = 1 ]; then
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html