printing from Textmate

Posted by Ed Tue, 07 Apr 2009 19:02:00 GMT

Textmate is a great lightweight text editor but printing functionality is very poor. Here’s a way suggested by Jeremy Wilkins to print out the current file or selection in small font size with line numbering. Put this command into a “Command” in the “Bundle Editor” and assign it to the keystroke ⌘P if you like:

a2ps --center-title=`basename "$TM_FILEPATH"` --font-size 8 -C --pretty-print --columns 1 -M A4 -R --tabsize=2 --line-numbers 5 -o - - | ps2pdf14 -sPAPERSIZE=a4 - /Users/fred/misc/tm_print/textmate_print.pdf && open -a /Applications/Preview.app /Users/fred/misc/tm_print/textmate_print.pdf

You will need a2ps and ps2pdf14 also. The latter you should have but the former is available through macports:

sudo port install a2ps

UPDATE

Another good solution which I use is to print from TextMate via vim which gives you a syntax-highlighted and line-numbered result (or however you choose to configure it.) In addition to vim it requires ps2pdf but these are easy to install with macports etc.

The only limitation is that the file needs to be saved first.

See this page which shows how to set up the macro as a TextMate ‘command’:

http://biztos.blogspot.com/2008/06/printing-with-textmate-vim-and-friends.htm

Comments

Leave a response

Comments