4

The goal is to print a set of *.cpp files on a network printer, but... in a way that the (color) printer prints the files like they appear in the c++ editor including the colors and highlighting. And all of this from the command line.

I succeeded in sending all the files to the network printer but they are (of course) all printed in black and white (text) format.

I used : lp -d 'printername' *.cpp

Is there a way to open the files in something like emacs and pass the print command to emacs from the command line?

BTW: I'm on mac OS X.

2

2 Answers 2

2

I would be highly surprised if you can do such a thing directly with lp. The following is the easiest solution I could think of.

There is a LaTeX package that can help you a lot: minted. You could write a script, that generates a .tex file (probably by \input{}) and uses this package for syntax-highlighting. Then you compile it, to obtain a .pdf with the colors that you wish. Sending it to printer is than the remaining step.

1

I think enscript might help you. I don't use it for code-formatting myself, but I do use it to print timestamps on text files I print.

I have a shell script in my ~/bin directory that will save it as a PostScript file that I can then print (directly printing, is of course an option). If that is helpful to you, I have it in a Gist here: https://gist.github.com/ryanaghdam/5103528. It takes a text file as the first argument ($1).

It is not installed on Mac OS X by default, but is available in Homebrew.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .