Sponsored Content
Full Discussion: enscript color
Top Forums Shell Programming and Scripting enscript color Post 302548451 by walforum on Thursday 18th of August 2011 12:05:02 PM
Old 08-18-2011
Hi was able to put some color in the file using a2ps
You can download a2ps from macports.

a2ps -R --column=1 --no-header --font-size=20 --pretty-print=js --highlight-level=heavy --pro=color --left-title=ITITLE1 --right-title=ITITLE2 -o temp.ps file.txt

_________________________________________________________________

Now this produces a file with only some of the words colored.

In order to make all the words colored I edited the js stylesheet.
Actually I created my own stylesheet and called it js2
You have to use awk ans sed commands to put the words from your file into the js2 file.

Here are the steps one by one.
1. First create a dummy file (js2.ssh) in the following directory opt/local/share/a2ps/sheets/ using command.

sudo vi /opt/local/share/a2ps/sheets/js2.ssh

2. Next link the file to your real js2.ssh file in your working directory
ln -s /opt/local/share/a2ps/sheets/js2.ssh ./js2.ssh

3. Next write a script to create js2.ssh file in your working directory here is a copy of my own called makejs2

##########################################
echo '# Style sheet for JavaScript'
echo '# Copyright (C) 2011 walforum'
echo ''
echo '#'
echo '# This file is part of a2ps.'
echo '#'
echo '#'
echo ''
echo 'style JavaScript is'
echo 'written by "Forumbaba <walforum@unix.com>"'
echo 'version is 1.1'
echo 'requires a2ps version 4.12g'
echo ''
echo 'first alphabet is'
echo ' "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"'
echo 'second alphabet is'
echo ' "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"'
echo 'case sensitive'
echo ''
echo 'documentation is'
echo ' "Keywords are generated from a text file"'
echo 'end documentation'
echo ''
echo 'keywords in Keyword are'
sed "s/[^a-z|^A-Z]/ /g;" $1 | sed "s/in/ /g;" | sed "s/is/ /g;"| sed "s/are/ /g;" | sed "s/ARE/ /g;" | sed "s/by/ /g;" | sed "s/end/ /g;" | sed "s/written/ /g;" | sed "s/first/ /g;"| sed '/^ *$/d' | sort -u | awk '{for(i=1;i<NF;i++)if(i%1==0){$i=$i","} }1' |awk '{ print " " $0 "," }'
echo ' love'
echo 'end keywords'
echo ''
echo 'keywords in Keyword_strong are'
sed "s/[^a-z|^A-Z]/ /g;" $1 | sed "s/in/ /g;" | sed "s/is/ /g;"| sed "s/are/ /g;" | sed "s/ARE/ /g;" | sed "s/by/ /g;" | sed "s/end/ /g;" | sed "s/written/ /g;" | sed "s/first/ /g;"| sed '/^ *$/d' | sort -u | awk '{for(i=1;i<NF;i++)if(i%1==0){$i=$i","} }1' |awk '{ print " " $0 "," }'
echo ' Jesus, God, Heaven, Lord, Father, Blessed, sin '
#echo ' All, sin, break, "case", catch, class, continue, default, delete, do, else, enum, '
#echo ' export, extends, final, finally, for, goto, if, implements, import, '
#echo ' "in", instanceof, interface, native, new, package, private, protected, '
#echo ' public, return, static, super, switch, synchronized, throw, throws, '
#echo ' transient, try, typeof, var, volatile, while, with '
echo 'end keywords'
echo ''
echo 'operators are'
echo ' (/(function)([[:blank:]]+)([^ \t(]+)/'
echo ' \1 Keyword_strong, \2 Plain, \3 Label)'
echo 'end operators'
echo ''
echo 'optional operators are'
echo ' # Actual'
echo ' && \wedge,'
echo ' || \vee,'
echo ' <= \leq,'
echo ' >= \geq,'
echo ' ! \not,'
echo ' # Protected from the above'
echo ' <<<=,'
echo ' <<=,'
echo ' >>=,'
echo ' >>>=,'
echo ' !=,'
echo ' !=='
echo 'end operators'
echo ''
echo 'sequences are'
echo ' # Regular expressions'
echo ' (/(=)/ # \1 = assignment'
echo ' /([[:blank:]]+)/ # \2 = spaces'
echo ' /(\/)/ # \3 = "/"'
echo ' /([^*\/])/ # \4 = first character of regexp'
echo ' \1 Plain, \2 Plain, \3 Plain, \4 String) String "/" Plain'
echo ' exceptions are'
echo ' "\\\\", "\\/"'
echo ' end exceptions,'
echo ' "/*" Comment Comment "*/" Comment,'
echo ' "//" Comment,'
echo ' C-string,'
echo ' "'" Plain String "'" Plain'
echo ' exceptions are'
echo "\\\\", "\\'"
echo ' end exceptions'
echo 'end sequences'
echo 'end style'
############################################


This script is run by ./makejs2 file.txt > js2.ssh

3. Next run the a2ps command again:
a2ps -R --column=1 --no-header --font-size=20 --pretty-print=js --highlight-level=heavy --pro=color --left-title=ITITLE1 --right-title=ITITLE2 -o temp.ps file.txt

That Should do it!!!!!!!!!!!!! Smilie
Enjoy
walforum

Last edited by walforum; 08-18-2011 at 01:45 PM..
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Enscript

I'm trying to print a perlscript file from nedit using the enscript command. It reads as follows: enscript -dbigbird -R -G -b"my_perl_script.pl" This is the printer command line when I print from nedit. I also have the language set to perl under preferences. This allows me to view comments... (1 Reply)
Discussion started by: mirzabhai
1 Replies

2. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies
All times are GMT -4. The time now is 08:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy