Title: print code with enscript Subject: Printing pretty from command line with style, using enscript enscript sends text document to the printer as post script. # install enscript emerge app-text/enscript # check what installed eix enscript [I] app-text/enscript Available versions: 1.6.4-r4 ~1.6.5 ~1.6.5.1 ~1.6.5.2 {nls ruby} Installed versions: 1.6.4-r4(04:22:12 PM 11/29/2008)(nls -ruby) Homepage: http://www.gnu.org/software/enscript/enscript.html Description: powerful text-to-postscript converter # List known media outputs: enscript --list-media known media: name width height llx lly urx ury ------------------------------------------------------------ Letterdj 612 792 24 40 588 768 A4dj 595 842 24 50 571 818 Letter 612 792 38 24 574 768 Legal 612 1008 24 24 588 984 A5 420 595 24 24 396 571 A4 595 842 24 24 571 818 A3 842 1190 24 24 818 1166 # It keeps a list of fonts in this mapp: strings /usr/share/enscript/afm/font.map AvantGarde-Demi agd AvantGarde-DemiOblique agdo AvantGarde-Book agw AvantGarde-BookOblique agwo Bookman-Demi bkd Bookman-DemiItalic bkdi Bookman-Light bkl Bookman-LightItalic bkli Courier-Bold cob Courier-BoldOblique cobo Courier com Courier-Oblique coo Helvetica hv Helvetica-Bold hvb Helvetica-BoldOblique hvbo Helvetica-Condensed hvc Helvetica-Condensed-Bold hvcb Helvetica-Condensed-BoldObl hvcbo Helvetica-Condensed-Oblique hvcdo Helvetica-Narrow hvn Helvetica-Narrow-Bold hvnb Helvetica-Narrow-BoldOblique hvnbo Helvetica-Narrow-Oblique hvno Helvetica-Oblique hvo Matrix matrix NewCenturySchlbk-Bold ncb NewCenturySchlbk-BoldItalic ncbi NewCenturySchlbk-Italic nci NewCenturySchlbk-Roman ncr Palatino-Bold pob Palatino-BoldItalic pobi Palatino-Italic poi Palatino-Roman por Symbol sy Times-Bold tib Times-BoldItalic tibi Times-Italic tii Times-Roman tir ZapfChancery-MediumItalic zcmi ZapfDingbats zd # # I had to: # shift my top margine down: # remove the headers # Use fixed width # enscript --margins=::50: --no-header --no-job-header --font=Courier8 -MLetter cis26Spring2011JohnStileLabEx4.c # # I created a script in my home dir # cat >> ~/bin/print_code.bash <<'END_SCRIPT' #!/bin/bash # Enscript prints a text file in post script in a nice way. file="$1" echo "Printing $file with:"; echo "enscript --margins=::50: --no-header --no-job-header --font=Courier8 -MLetter ${file}" enscript --margins=::50: --no-header --no-job-header --font=Courier8 -MLetter ${file} if [[ $? == 0 ]]; then echo "[OK] Enscript exited successfully." else echo "[!!] Enscript exit status $?. Check print job." fi END_SCRIPT #---------------------------------- # Custom fonts Make your own fonts #---------------------------------- mkdir ~/fonts/ # convert ttf to pfa # http://leuksman.com/linux/TrueType-HOWTO-5.html # copy fonts there cp .afm .pfa ~/fonts/ # Create map pushd ~/fonts/ mkafmmap popd # Create your config cat > ~/.enscriptrc <<'EOF' DefaultFancyHeader: emacs #PageLabelFormat: long Clean7Bit: 0 AFMPath: ~/fonts:/usr/local/share/enscript DefaultMedia: Letter NoJobHeaderSwitch: 1 UnderlayFont: Courier8 EOF