News for hackers. Stuff that matters.
Re:Grc - it's like stylesheets for your terminal by petercooper on Wednesday April 18, 2012 @02:10PM (#3859380)
I'm sure someone here will know the answer for this off the top of their head so.. how does this work under the hood? How does it get to act as a sort of 'filter' for stdout?

I've recently seen a system that can 'record' your terminal session for replay on the Web - http://ascii.io/ - whose 'recorder' forks off a psuedo terminal for this (https://github.com/sickill/ascii.io-cli/blob/master/bin/asci...). Would something like Grc use a similar approach or is there another way?

Re:Grc - it's like stylesheets for your terminal by zokier on Wednesday April 18, 2012 @02:41PM (#3859544)
I got this silly idea how to do it, I don't know if it works:

1. export your real $PATH to eg $REAL_PATH

2. clear $PATH (or set it to some dummy value)

3. Attach a wrapper script to command_not_found_handler, which would call the original command with REAL_PATH and pipes it to your filter (or colorizer or whatever).

Re:Grc - it's like stylesheets for your terminal by moonboots on Wednesday April 18, 2012 @02:39PM (#3859537)
This script inserts terminal escape sequences into text. These sequences are just text that the terminal interpret as color transitions.

Ascii.io transforms these terminal escape sequences into html/css, so Grc should work fine with it.

Re:Grc - it's like stylesheets for your terminal by petercooper on Wednesday April 18, 2012 @02:46PM (#3859579)
This script inserts terminal escape sequences into text.

I understand that part. But there's a screenshot where a "ping" is being done at a normal looking terminal and it just works without being explicitly piped through a program that does the above. What's the mechanism for piping all the terminal output through another process?

Re:Grc - it's like stylesheets for your terminal by moonboots on Wednesday April 18, 2012 @03:00PM (#3859645)
The initial grc command aliases commands like 'ping' to a modified command that processes the output[1].

[1] https://github.com/mxcl/homebrew/blob/7bbe7e9311ce95a141bf5f...

Re:Grc - it's like stylesheets for your terminal by petercooper on Wednesday April 18, 2012 @03:46PM (#3859863)
Ahh, aliases. Thanks :-) Makes sense. I was probably dreaming of a world where it'd pick up an IP address by regex in any terminal output.
Re:Grc - it's like stylesheets for your terminal by netherland on Wednesday April 18, 2012 @02:58PM (#3859636)
Those are supplied if you source the aliases that ship with the Homebrew formula: https://github.com/mxcl/homebrew/blob/7bbe7e9311ce95a141bf5f...
Re:Grc - it's like stylesheets for your terminal by SourPatch on Wednesday April 18, 2012 @05:24PM (#3860299)
I had an idea like this a while back, but as far as I know there is no shell support for it. Basically, you would install decorators in your current shell instance. The decorator could act as a filter for all stream io. Then you would not need any special commands or aliases, just configuration for how to highlight patterns.
Re:Grc - it's like stylesheets for your terminal by saurik on Thursday April 19, 2012 @02:32AM (#3861705)
To answer how programs like script (a little like ascii.io, but from decades ago and shipped with every Unix system), check out the manual page for forktty.