2019-12-03 22:12:44 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# opout: "open output": A general handler for opening a file's intended output,
|
|
|
|
# usually the pdf of a compiled document. I find this useful especially
|
|
|
|
# running from vim.
|
|
|
|
#
|
|
|
|
# from https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin
|
|
|
|
|
|
|
|
basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
|
|
|
|
|
2019-12-04 09:27:57 +00:00
|
|
|
openCompiledDoc() {
|
|
|
|
if [ -f "$basename".pdf ]; then
|
|
|
|
setsid "$FILEREADER" "$basename.pdf"
|
2019-12-28 09:07:05 +00:00
|
|
|
elif [ -f "$(echo "$basename" | sed 's/ /-/g')".pdf ]; then
|
|
|
|
setsid "$FILEREADER" "$(echo "$basename" | sed 's/ /-/g').pdf"
|
|
|
|
elif [ -f "$(echo "$basename" | sed 's/ /_/g')".pdf ]; then
|
|
|
|
setsid "$FILEREADER" "$(echo "$basename" | sed 's/ /_/g').pdf"
|
2019-12-04 09:27:57 +00:00
|
|
|
elif [ -f "$basename".html ]; then
|
|
|
|
setsid "$BROWSER" "$basename.html"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-12-03 22:12:44 +00:00
|
|
|
case "$1" in
|
2019-12-04 09:27:57 +00:00
|
|
|
# *.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$FILEREADER" "$basename".pdf >/dev/null 2>&1 & ;;
|
|
|
|
*.tex|*.md|*.[Rr]md|*.ms|*.me|*.mom) openCompiledDoc >/dev/null 2>&1 & ;;
|
|
|
|
*.[0-9]) openCompiledDoc >/dev/null 2>&1 & ;;
|
|
|
|
*.html) openCompiledDoc >/dev/null 2>&1 & ;;
|
2019-12-03 22:12:44 +00:00
|
|
|
esac
|