commit ac3b0c434172f56857e2cae8810647c285b20d7b
parent cbcb50f29fcab6ebdc3496d980a382bdb1404c59
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Mon, 29 Jun 2020 12:18:14 +0200
Add support for -o with tex files, add $opener declaration
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/.local/bin/compile b/.local/bin/compile
@@ -1,4 +1,5 @@
#!/bin/sh
+opener=xdg-open
show_help() {
echo "usage: ${0##*/} [OPTIONS] FILE ..."
@@ -77,6 +78,7 @@ handle_target() {
fi
printf 'compile_string=%s\n' "$compile_string"
run_compile "$compile_string" "$deps"
+ [ "$open" = 1 ] && $opener "${1%.tex}.pdf" || :
;;
*\.gp)
run_compile "gnuplot '$1'" "$1"
@@ -91,7 +93,7 @@ handle_target() {
*\.[0-9])
out="$(basename "${base}").pdf"
if [ "$open" = 1 ]; then
- run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$out' && xdg-open '$out'" "$1"
+ run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$out' && $opener '$out'" "$1"
else
run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$out'" "$1"
fi
@@ -99,7 +101,7 @@ handle_target() {
*\.mom)
out="$(basename "${base}").pdf"
if [ "$open" = 1 ]; then
- run_compile "pdfmom '$1' > '$out' && xdg-open '$out'" "$1"
+ run_compile "pdfmom '$1' > '$out' && $opener '$out'" "$1"
else
run_compile "pdfmom '$1' > '$out'" "$1"
fi
@@ -108,7 +110,7 @@ handle_target() {
die "File type $extension not supported\n";;
esac
else
- die "cannot open $1"
+ die "cannot read $1"
fi
}