mirror of
https://github.com/GRFreire/scripts.git
synced 2026-03-06 03:09:41 +00:00
latex_hotreload: new
This commit is contained in:
parent
57d4a3d4bc
commit
0974ea361a
1
bin/latex_hotreload
Symbolic link
1
bin/latex_hotreload
Symbolic link
@ -0,0 +1 @@
|
||||
../latex_hotreload/latex_hotreload.sh
|
||||
7
latex_hotreload/README.md
Normal file
7
latex_hotreload/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# latex_hotreload
|
||||
|
||||
## About
|
||||
-- about section here --
|
||||
|
||||
## Requirements
|
||||
-- any requirements --
|
||||
51
latex_hotreload/latex_hotreload.sh
Executable file
51
latex_hotreload/latex_hotreload.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
entry="$1"
|
||||
files_to_watch=$()
|
||||
|
||||
if [ -z "$entry" ]; then
|
||||
echo "Error: no entry provided. See --help for usage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$entry" == "--help" ]; then
|
||||
echo "Usage: latex_hotreload [OPTIONS] entry_tex_file"
|
||||
echo ""
|
||||
echo " OPTIONS:"
|
||||
echo " --help: show this help"
|
||||
echo ""
|
||||
echo " STDIN:"
|
||||
echo " The stdin should contain the files that should be watched for recompilation"
|
||||
echo " Defaults to ./*.tex"
|
||||
echo ""
|
||||
echo " ARGUMENTS:"
|
||||
echo " entry_tex_file: the entry latex file for compilation"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
output="$(echo "$entry" | sed 's/\.tex$/.pdf/')"
|
||||
|
||||
if test ! -t 0; then
|
||||
while IFS= read -r line
|
||||
do
|
||||
files_to_watch+=("$line")
|
||||
done
|
||||
|
||||
files=$(printf "%s" "${files_to_watch[*]}")
|
||||
files="$(echo $files | sed 's/ /\n/')"
|
||||
else
|
||||
files="$(find . -type f | grep "\.tex")"
|
||||
fi
|
||||
|
||||
echo $files | sed 's/ /\n/g' | entr -s "pdflatex -shell-escape $entry" &
|
||||
entr_pid=$!
|
||||
|
||||
while [ ! -f "$output" ]
|
||||
do
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
zathura "$output"
|
||||
|
||||
kill -s 2 "$entr_pid"
|
||||
Loading…
Reference in New Issue
Block a user