`pdfman` converts UNIX manual pages to PDF documents using Ghostscript's
`ps2pdf`(1) or Apple's `pstopdf`(1) command (included in macOS up to version 13
-"Ventura") and displays them by calling `open`(1) on the resulting PDF file.
+"Ventura") and displays them by calling `xdg-open`(1) or `open`(1) on the
+resulting PDF file.
This enhances the useability of the manual pages quite a bit, because you now
can make use of your preferred PDF file viewer and all of its functionality.
The `pdfman` script makes use of the following tools, which need to be available
on the local system in the default search `$PATH`:
-- `open`(1)
+- `xdg-open`(1) _or_ `open`(1).
- Either `ps2pdf`(1) of the Ghostscript suite _or_ `pstopdf`(1) which was
included in Apple macOS up to version 13 "Ventura".
man "$@"
exit $?
fi
-# Make sure required tools are available ...
-if ! command -v open >/dev/null; then
+
+# Detect "opener" to use ...
+if command -v xdg-open >/dev/null; then
+ open_command=xdg-open
+elif command -v open >/dev/null; then
+ open_command=open
+else
man "$@"
exit $?
fi
man "$@"
exit $?
fi
-[[ -n "$VERBOSE" ]] && echo "Using ${ps_to_pdf_function#*_}(1) ..."
+
+[[ -n "$VERBOSE" ]] && echo "Using ${ps_to_pdf_function#*_}(1) and ${open_command}(1) ..."
# Try to move old cache directory ...
if [[ -d "$HOME/.pdfman" && ! -d "$CACHE" ]]; then
fi
[[ -n "$VERBOSE" ]] && echo "Opening \"$PDF\" ..."
- open "$PDF"
+ $open_command "$PDF"
done