Skip to content

Instantly share code, notes, and snippets.

@gongzhitaao
Last active December 23, 2017 20:55
Show Gist options
  • Save gongzhitaao/fd2e87024a2ea37cc892 to your computer and use it in GitHub Desktop.
Save gongzhitaao/fd2e87024a2ea37cc892 to your computer and use it in GitHub Desktop.
Compile the most recently changed tex file

This make file finds the most recently changed tex file and compile it.

TEXI2PDF = texi2pdf
FLAGS = -c -p
# find the most recently changed tex file in 1 minute. If more than
# one files are changed within 1 minute, list only the most recent one.
cur := "$(shell find . -name '*.tex' -mmin -1 -printf '%TT\t%p\n' | sort | tail -1 | awk '{print $$2}')"
cur := "$(shell basename $(cur))"
all : recent
recent :
ifneq ($(cur),"")
$(TEXI2PDF) $(FLAGS) $(cur)
endif
.PHONY : all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment