git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-latexdiff: new command in contrib, to use latexdiff and Git

From
Steven Michalske <smichalske@gmail.com>
Date
Feb 16, 2012, 08:47 UTC
Message-ID
<94614DF7-9EE3-47CB-BC6E-97069597557E@gmail.com>
In-Reply-To
<vpq39abrxav.fsf@bauges.imag.fr>
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:
Show 95 quoted lines
> Tim Haga <timhaga@ebene6.org> writes:
> 
>> While testing your script on my office machine i discovered that the
>> following might be a problem:
>> 
>>> +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 1
> fi
> 
> +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
Previous: David AguilarNext: Matthieu Moy
Message 7 of 22 in “git-latexdiff: new command in contrib, to use latexdiff and Git”
  1. git-latexdiff: new command in contrib, to use latexdiff and GitMatthieu Moy, Feb 15, 2012
  2. Tim HagaFeb 15, 2012
  3. Matthieu MoyFeb 16, 2012
  4. git-latexdiff: new command in contrib, to use latexdiff and GitMatthieu Moy, Feb 16, 2012
  5. Jakub NarebskiFeb 16, 2012
  6. David AguilarFeb 16, 2012
  7. Steven MichalskeFeb 16, 2012
  8. Matthieu MoyFeb 16, 2012
  9. git-latexdiff: new command in contrib, to use latexdiff and GitMatthieu Moy, Feb 16, 2012
  10. Jakub NarebskiFeb 16, 2012
  11. git-latexdiff: new command in contrib, to use latexdiff and GitMatthieu Moy, Feb 16, 2012
  12. Matthieu MoyFeb 16, 2012
  13. Junio C HamanoFeb 16, 2012
  14. Junio C HamanoFeb 16, 2012
  15. Matthieu MoyFeb 17, 2012
  16. Junio C HamanoFeb 17, 2012
  17. Matthieu MoyFeb 17, 2012
  18. Junio C HamanoFeb 17, 2012
  19. Jakub NarebskiFeb 17, 2012
  20. Matthieu MoyFeb 20, 2012
  21. Junio C HamanoFeb 20, 2012
  22. Matthieu MoyFeb 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.