Created
April 11, 2017 16:59
-
-
Save markormesher/d953a365f7d3c3f8b46b4beced741d2a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# This script needs to go at the root of your source code. | |
# This script works with plain old Bash on Ubuntu - YMMV with other shells. | |
# You'll need to adjust the extensions and files that are included and ignored. | |
# DO NOT run this in the same folder as any other LaTeX work (look at the last line). | |
# This script is offered as-is and accept utterly no responsibility for whatever it does. | |
texFile="source.tex" | |
touch $texFile | |
cat<<EOF >$texFile | |
\documentclass[a4paper,landscape]{report} | |
\RequirePackage{listings} | |
\RequirePackage[usenames,dvipsnames]{color} | |
\RequirePackage[colorlinks=true,linkcolor=blue]{hyperref} | |
\RequirePackage{geometry} | |
\lstdefinestyle{customasm}{ | |
belowcaptionskip=1\baselineskip, | |
breaklines=true, | |
basicstyle=\footnotesize\ttfamily, | |
xleftmargin=.04\textwidth, | |
numbers=left | |
} | |
\geometry{a4paper, margin=1.6cm} | |
\pagenumbering{gobble} | |
\begin{document} | |
EOF | |
find . \( \ | |
\( \ | |
-name "*.kt" -or -name "*.js" -or -name "*.coffee" \ # These are the file | |
-or -name "*.scss" -or -name "*.xml" -or -name "*.json" \ # types I care about | |
-or -name ".gitignore" -or -name "*.gradle" -or -name "*.sh" \ # for my project. | |
\) \ | |
-and -not -path "*datasets*" \ # Ignore everything in the datasets folder | |
-and -not -name "*src2pdf*" \ # Ignore this file | |
\) \ | |
-printf '%h\0%d\0%p\n' \ | |
| sort -t '\0' -n \ | |
| awk -F '\0' '{print $3}' \ | |
| sort \ | |
| sed 's/^\..//' \ | |
| while read fileName; do | |
cleanName=$(echo $fileName | sed 's/_/\\_/g') | |
echo "\newpage" >> $texFile | |
echo "\textbf{$cleanName}" >> $texFile | |
echo "\lstinputlisting[style=customasm]{$fileName}" >> $texFile | |
done | |
echo "\end{document}" >> $texFile | |
pdflatex $texFile -output-directory . | |
pdflatex $texFile -output-directory . | |
rm *.aux *.bak *.bbl *.blg *.glg *.glo *.gls *.idx *.ist *.log *.out *.tex *.toc > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment