Skip to content

Instantly share code, notes, and snippets.

@maksimil
Created December 9, 2022 11:24
Show Gist options
  • Save maksimil/20e3e7df74174b80e2cba901c2601a77 to your computer and use it in GitHub Desktop.
Save maksimil/20e3e7df74174b80e2cba901c2601a77 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
buildroot="build"
srcroot="src"
filepath=$1
filename=$(python3 -c "
import os
basename=os.path.basename(\"$filepath\")
print(os.path.splitext(basename)[0])
")
dirname=$(python3 -c "
import os
dirname=os.path.dirname(\"$filepath\")
srcpath=os.path.relpath(dirname, \"$srcroot\")
print(os.path.join(srcpath, \"$filename\"))
")
builddir=$(printf "%s/%s" "$buildroot" "$dirname")
# pdffilename=$(printf "%s/%s.pdf" "$builddir" "$filename")
# creating the build dir
mkdir -p "$builddir"
# creating pdf file if it doesn't exist
# if [ ! -f "$pdffilename" ]; then
# touch "$pdffilename"
# fi
# start the latexmk
latexmk "$filepath" -pvc -pdf -outdir="$builddir" \
-e '$pdf_previewer=q[evince %S];'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment