Created
November 19, 2016 19:38
-
-
Save timvieira/462f0d5cfeb2b035c9e2819a5d5fc8b4 to your computer and use it in GitHub Desktop.
Make wrapper - Guesses what I meant when there was no Makefile in the current directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function yellow { echo -e "\e[33m$@\e[0m"; } | |
# Wrapper around make, which covers building different project types, when an | |
# actual Makefile isn't present. | |
function make { | |
if [[ -e Makefile ]]; then | |
yellow "[make] found Makefile" | |
/usr/bin/make $@ | |
else | |
yellow "[make] No Makefile found" | |
if [[ -e setup.py ]]; then | |
yellow "[make] python setup.py build_ext -i" | |
python setup.py build_ext -i | |
else | |
# Compile most-recently modified tex file, if one exists. | |
local tex=`ls -t *.tex 2>/dev/null |head -n1` | |
if [[ -n $tex ]]; then | |
yellow "[make] latexmk $tex" | |
latexmk -pdf $tex | |
local pdf=`echo $tex |sed -e 's/tex$/pdf/'` | |
xdg-open $pdf # or whatever file opening utility you like. | |
fi | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment