我想将已更改的Tex文件从Git转换为Bash变量,以便可以自动执行已更改的tex文件的编译过程。
示例
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Article/main.tex
从git获取路径后,我想在其中使用命令pdflatex Article/main.tex
运行脚本的地方。
建议
有很多选择。我感谢Lea Gris在这里致力于解决方案。
1。对于单个更改的Tex文件,将执行此操作
pdflatex `git diff --name-only | grep *.tex`
2。对于更改的Tex文件的许多目录,它们必须具有不同的名称,其中已编译的PDF文件将出现在当前目录中。
git diff --name-only '*.tex' | xargs -l1 pdflatex
3。对于同名的,已更改的Tex文件,Lea评论(尚未运行,试图理解它,我选择解释here)]]
git diff --name-only '*.tex' | xargs -l1 -I{} sh -c 'cd "${1%/*}"; pdflatex "$1"' _ {}
固体溶液
尝试Latexmk,make的特殊版本,仅针对LaTeX进行所有重新编译和重建的事情