Skip to content

Commit b22ed9a

Browse files
committed
fix(tex): use available opener command for cross-platform PDF opening
1 parent 3367804 commit b22ed9a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

app/tex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# SPDX-FileCopyrightText: 2020-2026 David Rabkin
44
# SPDX-License-Identifier: 0BSD
55
#
6-
# shellcheck disable=SC1091 # File not following.
6+
# shellcheck disable=SC2034,SC1091 # Variable appears unused, file not following.
7+
readonly BASE_APP_VERSION=0.9.20260331
78
. base.sh
89
[ "$#" -eq 1 ] || die tex: try tex [file name]
910
isreadable "$1" || die Unable to read file "$1".
@@ -24,6 +25,14 @@ readonly \
2425
NME \
2526
PDF="$NME".pdf \
2627
TEX="$NME".tex
28+
if cmd_exists -q open; then
29+
OPENER=open
30+
elif cmd_exists -q xdg-open; then
31+
OPENER=xdg-open
32+
else
33+
die Neither open nor xdg-open is available.
34+
fi
35+
readonly OPENER
2736

2837
# Do not worry about file cleaning on exit. Garbage collector will remove the
2938
# temporarily directory.
@@ -35,4 +44,4 @@ if ! tex --interaction=batchmode "./$TEX" >/dev/null 2>&1; then
3544
fi
3645
dvipdfm "./$DVI" >/dev/null 2>&1
3746
cp "./$PDF" "$OLDPWD"
38-
open "$OLDPWD/$PDF"
47+
"$OPENER" "$OLDPWD/$PDF"

0 commit comments

Comments
 (0)