How do I print the source code of a bash script (on paper)?
Question
I need to print some Bash script on paper. Any recommendations on how to get a nice output with syntax highlighting and all that?
I've tried TextMate, but the output had huge fonts (and no syntax highlighting, no colors).
Solution 3
I ended up using Bundles > TextMate > Create HTML in TextMate and then printing the HTML.
OTHER TIPS
You can use gvim to convert the script to colorized html. (Open script in gvim then select 'Syntax' menu then 'Convert to html'). Then you can print that html using firefox.
I use enscript. It's a command line tool for formatting text for printing. It includes support for bash syntax highlighting. It is easy to configure for line numbering and row highlighting.
Generally I tell it to print to a file so I can look at it in Preview and tweak any options.
You can pull it out of MacPorts if you don't have it already.
I usually prefer enscript, and these are my favorite options:
enscript -2rG -Ebash <filename> -P<printername>
- -2 -> print two pages per sheet
- -r -> rotate 90º
- -G -> fancy headers
- -Ebash -> syntax highlight per bash
If you are tired of writing this all the time, you can write an alias or put it in a makefile.
Komodo Edit is free, works in Linux, OSX and Windows, does great job highlighting many different formats.