views:

116

answers:

5

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).

+1  A: 

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.

Geos
Note that this is accessible in normal Vim, i.e. without menus, as :[range]TOhtml
Jefromi
+1  A: 

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.

David Dorward
A: 

I ended up using Bundles > TextMate > Create HTML in TextMate and then printing the HTML.

J. Pablo Fernández
A: 

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.

dalloliogm
A: 

Komodo Edit is free, works in Linux, OSX and Windows, does great job highlighting many different formats.

Marcin