Supercat Text Colorizer

The application Supercat colors any input text based on the type of file and a set of rules associated with the file type. The rules are used to match strings found in the input text and can be specified using simple characters or strings, regular expressions and special time-formatting rules. Supercat is flexible and extensible; new file types can be added without software development.

You can download Supercat (at the time of writing the latest version was 0.5.3) at Supercat is also available in Gentoo's portage system and Ubuntu's to-be-released Hardy Heron. Installing Supercat is fairly straightforward -- the only thing you need to specify is the --system-directory 'configure' option. Once installed, you can run Supercat on numerous files. For example:

$> spc file.c

This presents you with a colorized listing (similar to how Vim colors text). Supercat tries to figure out the file type based on the file suffix or, in the case of files with the extension .log, Supercat removes the suffix and looks up the file name (e.g., error.log is file type error). The user can explicitly override the file type on the command line.

All rules for colorizing text are stored in files with names of the form spcrc-ext, where "ext" is the file type. These files are stored in the configured "system directory" or else your private ~/.spcrc directory.

All rules for colorizing text are stored in files with names of the form spcrc-ext, where "ext" is the file type. These files are stored in the configured "system directory" or else your private ~/.spcrc directory. For example, the rules for a C source code file in spcrc-c might look like:


########## ### # # #
Red        red b
Yellow     yel b    
Yellow     yel b   s
Cyan       cya     s case
Cyan       cya     s return
Cyan       cya     s default
Cyan       cya b    
Green      grn       (do)[[:space:]]*{
Green      grn       (break|continue)[[:space:]]*;
Magenta    mag   
blu b     [^[:alnum:]_]([[:digit:]]+)
Yellow     yel      
Yellow     yel       <(.*)>
Magenta    mag
    c :;

Matching is performed using the information in the pattern at the end of each line in the configuration file. If a portion of a line matches the pattern then the matching characters are given the specified color. The type of matching is specified in the 'T' column and defaults to REGEXP.

The other columns specify the video coloring attributes to the used. "COL" indicates the console color; "A" is an optional video attributes (e.g., bold, underline); "N" governs the number of times a match is applied to a line. The "HTML COL" column is there because Supercat supports outputting its colorized text in HTML format for viewing with a Web browser.

Supercat provides flexibility and extensibility without requiring programming. There are numerous other options and goodies that Supercat has to offer, but I'll let you find them as they are extensive and out of the scope of this short HOWTO.

This Tech Tip was brought to us by Thomas in New Jersey, USA. Thanks, Thomas!

Instant fame is easy at Linux Journal. Just send us your useful Tech Tips to share with the Linux Community, and we'll send you a cool t-shirt for your efforts!

Please note: Tech Tips featured in this specific section of are kindly brought to us by readers and are not necessarily tested by editors.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState