Created
July 23, 2022 20:43
-
-
Save nate-xyz/a73d1e820a260c0f60d42673152c54c1 to your computer and use it in GitHub Desktop.
bash script to create printabe pdf of your code, using enscript, ps2pdf, and pdftk
This file contains hidden or 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 | |
| i=0 | |
| mkdir ./tmp | |
| for file in $(find . -name \*.$1) | |
| do | |
| if [ $(cat $file | wc -l) -gt 0 ] | |
| then | |
| enscript -1RG --line-numbers --margins=0:0:0:0 -p ./tmp/output-$i.ps $file | |
| ps2pdf ./tmp/output-$i.ps ./tmp/output-$i.pdf | |
| ((i=i+1)) | |
| fi | |
| done | |
| filelist="" | |
| n=$(find ./tmp -name \*.pdf | wc -l) | |
| ((n=n-1)) | |
| for ((i=0;i<=$n;i++)); | |
| do | |
| filelist+="./tmp/output-${i}.pdf " | |
| done | |
| pdftk ${filelist} cat output $1-output.pdf | |
| sudo rm -R ./tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment