Printing source code in Mac OS X
Figured out that there are some difficulties on printing source code in Mac OS, especially in lightweight text editors like Sublime Text 2 which doesn’t support printing right now and TextMate which in my opinion produces not cozy and beautiful result.
There is nice program called enscript and it is probably can do a lot of good things, but in our case can produce a PostScript file with printed code. In Mac OS X it can be installed using brew, brew install enscript
.
So, here is a good example using encsript :
Everything is pretty clear, but
- 1 is for printing one page per sheet
- -r is for album mode, remove it to print for usual book mode
- -p - for producing ps output, after that it piped to file ~/out.ps
- –color=0 for black/white mode
- –color=1 for colored mode
- -c is for cutting lines, if they are bigger than the actual width of a sheet. There is also –word-wrap option
Another example with automatic conversion to pdf using ps2pdf
:
In conclusion, a good idea for you - you can open your start-up project on printing code files
(ruby, perl, js, c#, etcetera) with right click in Mac OS X using Automation services. Simple problem, simple solution.