Update build watch script to re-use build dir
This commit is contained in:
parent
b516408de8
commit
17afb50e51
1 changed files with 24 additions and 7 deletions
31
flake.nix
31
flake.nix
|
@ -132,11 +132,19 @@
|
||||||
category = "general commands";
|
category = "general commands";
|
||||||
help = "build the PDF";
|
help = "build the PDF";
|
||||||
command = ''
|
command = ''
|
||||||
builddir=$(mktemp -d --tmpdir=/tmp)
|
if [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
builddir=$1
|
||||||
|
else
|
||||||
|
builddir=$(mktemp -d --tmpdir=/tmp)
|
||||||
|
fi
|
||||||
${emacs}/bin/emacs -batch -load build.el
|
${emacs}/bin/emacs -batch -load build.el
|
||||||
${full-texlive}/bin/latexmk -f -pdf -lualatex -interaction=nonstopmode -output-directory="''${builddir}" book.tex
|
${full-texlive}/bin/latexmk -f -pdf -lualatex -interaction=nonstopmode -output-directory="''${builddir}" book.tex
|
||||||
mv "''${builddir}"/book.pdf .
|
mv "''${builddir}"/book.pdf .
|
||||||
rm "''${builddir}" -rf
|
if ! [ $# -eq 1 ]
|
||||||
|
then
|
||||||
|
rm "''${builddir}" -rf
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -144,17 +152,26 @@
|
||||||
category = "general commands";
|
category = "general commands";
|
||||||
help = "watch main file and build on change";
|
help = "watch main file and build on change";
|
||||||
command = ''
|
command = ''
|
||||||
trap "exit 0" SIGINT SIGTERM
|
builddir=$(mktemp -d --tmpdir=/tmp)
|
||||||
|
|
||||||
|
trap "rm \"''${builddir}\" -rf; exit 0" SIGINT SIGTERM
|
||||||
|
if [ -e book.pdf ]
|
||||||
|
then
|
||||||
|
time=$(stat -c %Y book.pdf)
|
||||||
|
else
|
||||||
|
time=$(date "+%s")
|
||||||
|
build "''${builddir}"
|
||||||
|
fi
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
time=$(date "+%s")
|
|
||||||
echo "Waiting for change..."
|
|
||||||
${pkgs.fswatch}/bin/fswatch -1 book.org >/dev/null
|
|
||||||
while [ "$time" -lt "$(stat -c %Y book.org)" ]
|
while [ "$time" -lt "$(stat -c %Y book.org)" ]
|
||||||
do
|
do
|
||||||
time=$(date "+%s")
|
time=$(date "+%s")
|
||||||
build
|
build "''${builddir}"
|
||||||
done
|
done
|
||||||
|
time=$(date "+%s")
|
||||||
|
echo "Waiting for change..."
|
||||||
|
${pkgs.fswatch}/bin/fswatch -1 book.org >/dev/null
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue