Posted by tong on Tue 21 Nov 2006 at 13:07
Recently there was an article on this site discussing adding colour highlighting to grep. Now we're going to look at a general purpose highlighting tool called histring.
If you like to work in console more than X, and like text tools more than GUI ones then histring is definitely a tool for you!
histring simply highlights strings using ANSI terminal escape codes. It is extremely small and lighting fast. I almost use it everywhere in my script where I need a quick peek into large output. Moreover, you almost don't need to learn it, as its syntax is almost identical to grep.
The following two example will turn you into a histring-pro:
zip -t *.zip 2>&1 | histring -fEi 'warning |bad CRC|error: ' | less
This example will show me the content of my .zip files. More importantly, it will alert me if any of the zip files has any problem.
Once you get used to it, you can't image the life without it.
The following is another nifty alias that I use more often than anything else, to accept output from diff or rcsdiff to highlight diff files:
histring -fE '^Comparing files .*|^diff .*' | histring -c yellow -fE '^\-.*' | histring -c green -fE '^\+.*'
With that, who needs to wait 0.5s for tkdiff? :-)
Also, with that I wrote another alias to compare rcs file version by version. I guess no other diffing tool has such an ability to show how things evolve.
histring is available from the following URL:
A Debian package is available through the grml repository (just run run "apt-get update; apt-get install histring" on your grml system):
If you are not using grml, it is still OK, just add the following to your /etc/apt/sources.list and run the above commands:
# main grml repository: deb http://grml.org/repos ./