I wanted to print multiple code files, so ended up using the command below. It looks for #elixir files and combines them into
output.ex along with the filenames.
for f in $(find . -name *.ex*); do
# edit: don't use the next line as-it, see the post below.
# echo "# $f\n\n$(cat $f)\n\n#######\n" >> output.ex
(That will also find vim’s backup files like
fname.ex~, so it might not won’t work well as-is unless you clean the directories.)
Then the output can be converted to postscript with this (though the syntax highlighting didn’t work).
enscript --pretty-print --color output.ex -o output.ps
I ended up running the
output.ex file through Vim to generate the postscript file with syntax highlighting:
vim -me -e -c ":hardcopy >%.ps" -c ":q" output.ex
If anyone has other tips for printing code, leave a comment below.
See also Advanced Linux Printing guide.