?

Log in

No account? Create an account

Previous Entry | Next Entry

Syntax highlighter for 'tail'?

I'd love some way of tying vim's syntax abilities, or ... well, really anything, to some generic output stream--

I want to tail -f access.log | synhighlighter

or cat myccode.c | synhighlighter

or some such.

Does some unix such thing exist? Could something be hacked to make it exist simply?

Sent to LazyWeb for some love.

Comments

( 8 comments — Leave a comment )
nibot
Feb. 16th, 2005 11:28 am (UTC)
Could something be hacked to make it exist simply?

yeah. how do you want to define a "syntax highlighting"? i mean, in what way will you describe the patterns to colors mapping?
kaolinfire
Feb. 16th, 2005 11:30 am (UTC)
That's the thing, I want a tool that already knows how to do that. Prebuilt. Take vim's how-to-highlight files, or emacs', or whatever. Maybe since you're doing pipes, you could pass the implied file extension as a way of naming which particular syntax to do.
nibot
Feb. 16th, 2005 11:39 am (UTC)
Maybe since you're doing pipes, you could pass the implied file extension as a way of naming which particular syntax to do.

eeehhh? "implied file extension"??

That's the thing, I want a tool that already knows how to do that. Prebuilt. Take vim's how-to-highlight files, or emacs', or whatever.

I mean, I've never looked at one of those formats either.

The basic problem you describe is pretty easy. You have a lexical analyzer to tokenize the file, and then you couple it to a pretty-printer that just maps token types to colors. Colors you make using good old VT100/ANSI escape sequences.

c.f. http://splorg.org:8080/people/tobin/projects/others/prettyc/

hacking this functionality into http://www.gnu.org/software/src-highlite/source-highlight.html would be nifty.
kaolinfire
Feb. 16th, 2005 11:45 am (UTC)
eeehhh? "implied file extension"??

ie pass -f c if you're piping through a c file, -f log if you're piping through an apache log file, ...

I'm familiar with vt100/ansi, less familiar with lex et. al, and loathe to reinvent this particular tool. source-highlight looks a lot like what I was hoping for. :)

Especially with notes like "you can use this program with less". It's just a hop, skip, and a jump from less to tail... maybe. :)

I'll have to give it a stab.
(Anonymous)
Feb. 16th, 2005 12:09 pm (UTC)
Vim as pager
Well, vim can do it, but syntax highlighting a stream would require the user telling what type it is. $VIMRUNTIME/macros/less.sh file.c should work just fine.

vim as pager (http://www.vim.org/tips/tip.php?tip_id=121) (mostly less.vim included in vim6.0+)

Leland Johnson
lfaren
Feb. 16th, 2005 12:59 pm (UTC)
colortail
I used a package called colortail. I've also piped through Python and Perl scripts to do the same thing, but colortail is easier. Give it a shot. Should be available for most distros. Good luck!
(Anonymous)
Feb. 17th, 2005 07:51 am (UTC)
Vi pipe
http://www.cs.duke.edu/~des/vip.html

May I suggest actually piping to vi?
nibot
Feb. 17th, 2005 09:20 pm (UTC)
on the subject of unix pipes, this thing looks awesomely 31337:

http://www.livejournal.com/users/ttroxell/22789.html
( 8 comments — Leave a comment )

Latest Month

February 2016
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
2829     

Tags

Page Summary

Powered by LiveJournal.com
Designed by chasethestars