SPC(1)

πŸ“¦
version 0.5.8 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– SPC(1) β€” like, the manual page, but make it make sense πŸ’–

okay bestie, gather round, because this is spc(1) from the User Commands corner of the manual, and honestly? it's giving colorize-and-print-to-stdout main character energy. let's go πŸ¦‹


✨ NAME ✨

spc β€” colorize stuff and print it to standard output. that's the whole vibe, no cap. πŸ’…


🌸 SYNOPSIS 🌸

spc [OPTION] [FILE]...
    [-c file|-C directory]
    [-t type]
    [-e color|(RE)]
    [-E color,attribute,count,type|(RE)]

πŸŽ€ DESCRIPTION πŸŽ€

so basically: it colorizes specific patterns in the input and writes them to standard output. and if you want, the output can also be formatted as a whole web page. iconic behavior honestly.

  • -c | --config=FILE β€” point it at a non-standard config file πŸ“
  • -C | --config-dir=DIR β€” point it at a non-standard config file directory πŸ“‚
  • -d | --debug β€” turn on debug info. and yes you can stack it: multi-level -d -d ... πŸ”
  • -e | --cmd-s β€” short-form command-line color instruction ✨
  • -E | --cmd-l β€” long-form command-line color instruction πŸ’«
  • -h | --help β€” display this help and dip out πŸ‘‹
  • -m | --matching β€” print only the lines that have matches 🎯
  • -n | --line-numbers β€” slap a line number in front of every line πŸ”’
  • -r | --reverse β€” reverse black and white πŸ–€πŸ€
  • -R | --nohomedir β€” don't go looking in ~/.spcrc for config files 🚫🏠
  • -S | --printsysdir β€” print SYSTEM_DIRECTORY and exit πŸ–¨οΈ
  • -t | --type=TYPE β€” specify the effective file type or extension 🏷️
  • -v | --version β€” output version info and exit πŸ“œ
  • -w | --webpage β€” generate a web page 🌐

and if you give it no FILE at all, it just reads standard input. easy. 🫢


okay so this part matters: config files are required for proper operation. like, required required. fr fr. πŸ”₯

it finds them by searching a bunch of locations until it hits a proper one. the directories and file names get searched in this exact order, looking for a file with the extension .foo β€” or, if you used the -t foo option, that extension instead. and if you used -C bar, then its place in the search is shown right there in the list too:

./.spcrc-foo

./.spcrc

~/.spcrc/spcrc-foo

~/.spcrc/spcrc

bar/spcrc-foo

bar/spcrc

SYSTEM_DIRECTORY/spcrc-foo

SYSTEM_DIRECTORY/spcrc

so how does it get that extension? it takes the characters after the final . in the file name. if there's no extension at all, it just uses the filename itself. 🧚

BUT β€” and this is the plot twist β€” if the extension is log, then extra processing happens. the filename, meaning the part of the path after the last /, gets used up to the first .. so for example, an apache log named apache.0.log ends up with an extension of apache. wild, right? 😭

and if you want to override all of that, the -t option is right there. πŸ‘‘


🌈 CONFIGURATION FILE FORMAT 🌈

SuperCat config files have a fixed columnar format β€” for readability and easy parsing. there are 6 fields per line, although only 2-3 of them actually require entries. the format is:

        1         2         3         4         5
1234567890123456789012345678901234567890123456789012345
HTML Color Name      Col A N T RE / String / Characters
#################### ### # # # ########################

now let's break down every single field, because we do not skip. πŸ’œ

🎨 HTML Color Name (columns 1-20)

optional field. it says which standard HTML color name to use when creating a web page. it's only required if you're using Supercat's -w option.

πŸ–οΈ Col - Color (columns 22-24)

this one is mandatory. it's the three character color name, and it can be one of:

blk, red, grn, yel, blu, mag, cya, whi

✨ A - Color Attribute (column 26)

a color attribute, and it takes one of these values:

'-':normal, 'b':bold, 'u':underline

πŸ”’ N - Number of matches to color (column 28)

a single digit number that tells it how many matches to color on a single line. '0' means all of them. a space ' ' defaults to '0':all.

🎯 T - Type of Match (column 30)

a single character, and here's the full menu:

  • r : regular expression
  • R : regular expression (case-insensitive)
  • s : string
  • c : characters
  • t : unix time conversion RE (MMDDHHMMSS)
  • T : unix time conversion RE (YYMMDDHHMM)
  • u : unix time conversion RE ( HH:MM:SS)
  • U : unix time conversion RE (YYYY:MM:DD)

a space ' ' defaults to 'r':RE.

okay and now the details, because these all behave differently:

  • an extended regular expression (see regex(7)) specifies the pattern to match and the pattern or sub-pattern(s) to color. the portions of the pattern in parentheses are the ones that get colored. πŸ‘‘
  • the string matches the exact string and colors it.
  • for the list of characters, each character is matched individually and colored.
  • the time RE extended regular expression specifies a pattern to match with one sub-pattern to color of the form ([0-9]{10}). this should match a 10 decimal digit Unix seconds since 01/01/1970. that number gets converted to the human readable form: MMDDHHMMSS or YYMMDDHHMM, replacing the same 10 columns. ⏰

🧡 RE / String / Characters - Attribute (columns 32-)

(yep, that's the field. go off.)


πŸ’» COMMAND LINE EXAMPLES πŸ’»

  • spc spc.c colorize the file spc.c.
  • cat spc.c | spc -t c read standard input, formatting it as a type C file, and write it to standard output.

🌟 CONFIGURATION FILE EXAMPLES 🌟

go take a peek at some of the config files delivered with SuperCat β€” you'll find them in the SYSTEM_DIRECTORY. but here are a few simple examples of the config file syntax so you can see the vibe:

Magenta              mag - 0 r ([0-9]{2}):([0-9]{2}):([0-9]{2})

color a time field HH:MM:SS, but not the colons.

Cyan                 cya     t ^([0-9]{10})

match a 10 decimal digit number at the beginning of a line, treat it as Unix seconds since epoch, and convert it to MMDDHHMMSS in cyan. πŸ’™

Cyan                 cya   1 t ([0-9]{10})

similar to the one above, but using numeric count.

Yellow               yel       "(.*)"

color a quoted string in yellow. πŸ’›


πŸ‘‘ AUTHORS πŸ‘‘

written by Mark P Anderson and Thomas G Anderson. tested by David B Anderson. maintained by Thomas G Anderson.


😀 REPORTING BUGS 😀

report bugs to <bug-spc@nosredna.net>. please and thank you, bestie. πŸ™ˆ


Copyright Β© 2007-2015 Thomas G Anderson

this is free software. you may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. there is NO WARRANTY, to the extent permitted by law.

like, genuinely no warranty. don't come for us. πŸ’€

okay that's the whole page!! this was spc version 0.5.8, dated January 2022, and honestly? she ate. periodt. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from