Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for an OS X application to nicely format and print source code from a variety of programming languages.

  • Line numbers would be nice
  • Constant width font
  • Printing the contents of the clipboard would be a real plus

Does something like this exist (besides the obvious programmers' editors), free or reasonably priced?

share|improve this question
up vote 6 down vote accepted

You will find a nice answer over at sister site superuser. It involves a terminal program called enscript which comes with lot's of options and I know at least of one support file for extending its capabilities to print Ruby code.


I just noticed the "clipboard" part of the question. The clipboard content can be accessed from the command line and fed to enscript using pbpaste as mentioned in Matteo answer.

share|improve this answer

If you don't want to use the terminal for this task and want a mac 'application' you should look at 'Text Wrangler' by Bare Bones Software. It is freeware, which fits your 'low price' request ;)

I use it to print out smaller runs of text, and use it specifically for the line number feature.

share|improve this answer

See also GNU Source-highlight, which supports many input languages and several output formats.

share|improve this answer

If you are familiar with the command line you could use a2ps (free and open source) which can be installed via MacPorts (install MacPorts and then sudo port install a2ps) or Homebrew (install Homebrew and then brew install a2ps).

For example:

a2ps -1 --line-numbers=5 -g source.c

will print source.c with syntax highlighting (-g) and line numbers each 5 pages. See the manual page for additional options. It supports a wide variety of source formats.

To print the content of the clipboard:

pbpaste | a2ps -1 --line-numbers=5

pbpaste prints the content of the clipboard to standard output which is read by a2ps.

share|improve this answer
If open source apps dont work for you, I recommend TextMate from – David DelMonte Jan 15 '13 at 18:53
You can also get a2ps from Homebrew ( Some people like it better than MacPorts. – chrish Jan 16 '13 at 17:53
@chrish Thanks I updated the answer – Matteo Jan 16 '13 at 20:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.