Skip to content

Commit

Permalink
Merge pull request #29 from AxelZvb/feature/adding_no_output_mode
Browse files Browse the repository at this point in the history
Changed default xdg-open output to /dev/null
  • Loading branch information
patbro authored Nov 12, 2019
2 parents b26aea9 + 93e2e48 commit 252faba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ It can be viewed using your system's PDF viewer by running:
bazel run :my_report_view
```

If you want to get the output from the PDF viewer you can run:

```
bazel run :my_report_view_output
```

# Using packages

By default, `latex_document()` only provides a version of TeXLive that
Expand Down
8 changes: 8 additions & 0 deletions latex.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@ def latex_document(name, main, srcs = []):
main = main,
)

# Convenience rule for viewing PDFs.
native.sh_binary(
name = name + "_view_output",
srcs = ["@bazel_latex//:view_pdf.sh"],
data = [name + ".pdf"],
)

# Convenience rule for viewing PDFs.
native.sh_binary(
name = name + "_view",
srcs = ["@bazel_latex//:view_pdf.sh"],
data = [name + ".pdf"],
args = ["None"],
)
9 changes: 8 additions & 1 deletion view_pdf.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/bin/sh
filename="$(find . -name '*.pdf')"

if type xdg-open > /dev/null 2>&1; then
# X11-based systems (Linux, BSD).
exec xdg-open "${filename}" &

if [ $1 = "None" ] ; then
exec xdg-open "${filename}" 2>/dev/null &
else
exec xdg-open "${filename}" &
fi

elif type open > /dev/null 2>&1; then
# macOS.
exec open "${filename}"
Expand Down

0 comments on commit 252faba

Please sign in to comment.