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.

One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix