News for hackers. Stuff that matters.

nojhan

That's because the log was already colored (the word "fail" in red). As colout tries to color the whole line, the previous end escape character is interpreted by the terminal before the last one :

    <red>* This is a colored line [<red>fail<end>]</end>
(You can use the `--debug` switch of colout to get hints about such problems).
You've got a too old version, update to the current one and you will see something like:

    [:~/code/colout/colout] parse_r+* ± colout -r x
    Available resources:
    STYLES: reverse, bold, italic, normal, conceal, rapid_blink, faint, underline, blink
    COLORS: blue, none, black, yellow, cyan, green, magenta, white, red
    SPECIAL: random, Random, scale, Scale, colormap
    THEMES: g++, cmake, json, perm
    COLORMAPS: rainbow, jet72, Spectrum, spectrum, Rainbow
    LEXERS: Cucumber, abap, ada, ahk, antlr, antlr-as, antlr-cpp, antlr-csharp, antlr-java, antlr-objc, antlr-perl, antlr-python, antlr-ruby, apacheconf, applescript, as, as3, aspx-cs, aspx-vb, asy, basemake, bash, bat, bbcode, befunge, blitzmax, boo, brainfuck, c, c-objdump, cfm, cfs, cheetah, clojure, cmake, coffee-script, common-lisp, console, control, cpp, cpp-objdump, csharp, css, css+django, css+erb, css+genshitext, css+mako, css+myghty, css+php, css+smarty, cython, d, d-objdump, delphi, diff, django, dpatch, duel, dylan, erb, erl, erlang, evoque, factor, felix, fortran, gas, genshi, genshitext, glsl, gnuplot, go, gooddata-cl, groff, haml, haskell, html, html+cheetah, html+django, html+evoque, html+genshi, html+mako, html+myghty, html+php, html+smarty, html+velocity, hx, hybris, ini, io, ioke, irc, jade, java, js, js+cheetah, js+django, js+erb, js+genshitext, js+mako, js+myghty, js+php, js+smarty, jsp, lhs, lighty, llvm, logtalk, lua, make, mako, maql, mason, matlab, matlabsession, minid, modelica, modula2, moocode, mupad, mxml, myghty, mysql, nasm, newspeak, nginx, numpy, objdump, objective-c, objective-j, ocaml, ooc, perl, php, postscript, pot, pov, prolog, properties, protobuf, py3tb, pycon, pytb, python, python3, ragel, ragel-c, ragel-cpp, ragel-d, ragel-em, ragel-java, ragel-objc, ragel-ruby, raw, rb, rbcon, rconsole, rebol, redcode, rhtml, rst, sass, scala, scaml, scheme, scss, smalltalk, smarty, sourceslist, splus, sql, sqlite3, squidconf, ssp, tcl, tcsh, tex, text, trac-wiki, v, vala, vb.net, velocity, vim, xml, xml+cheetah, xml+django, xml+erb, xml+evoque, xml+mako, xml+myghty, xml+php, xml+smarty, xml+velocity, xquery, xslt, yaml
That's a bug I'm still trying to fix, but the argparse module made it somewhat difficult to find an elegant solution.

An easy workaround is to indicate a fake pattern argument:

    colout -r x
You use the "zero or more" * operator, which will match empty strings in front of the "%". But an empty string cannot be converted to a float. Just use the "at least one" operator: +. Also, the scale is 0,100 by default, you can omit it.

    df -h | colout "([0-9]+)%" scale
It's not really a replication, as colout just _USE_ the pygments library. Colout just add the possibility to color code that is located inside a text that should not be colored, which pygmentize cannot do:

    colout -a -s Python monokai < code.py # just like pygmentize
    colout "^(:*)'(:*)'(:*)$" blue,python,blue < code.py # just the code 'inside quotes', not the rest of the line
Re:Colout – add colors to a text stream in your terminal on Thursday June 06, 2013 @04:21PM (#5834918)
There is some incompatibility, like the gettext module in the g++ theme, the way themes are imported, unicode support, the print statement… But maybe it's still possible to write a code that work on both versions?
Re:Colout – add colors to a text stream in your terminal on Thursday June 06, 2013 @03:41PM (#5834697)
You can, it's just a matter of knowing how to write a function for your shell.
Re:Colout – add colors to a text stream in your terminal on Thursday June 06, 2013 @03:38PM (#5834683)
It should not be too difficult to use the same config files in colout, btw.
Re:Colout – add colors to a text stream in your terminal on Thursday June 06, 2013 @12:34PM (#5833442)
The `-h` switch show the help, but the `-r` show the resources loaded at startup.

Alias for common use cases are named "themes" in the list of resources.

Re:Colout – add colors to a text stream in your terminal on Thursday June 06, 2013 @12:32PM (#5833425)
Indeed. Having to build configuration file for each command was a pain in the ass. Colout is better integrated in my shell workflow and shows that config files are not mandatory (but colout themes do just the same).

Plus, colout have a tons of additional features (256-colors mode, colormaps, etc.).

Re:An adaptive prompt for Bash and Zsh on Sunday April 21, 2013 @06:16AM (#5584477)
To be honest, just because I've tried to pass this link in hackernews several times without success, with different combination of keywords/users.

I was a little bit shameful at the beginning, but the overwhelming success (from the perspective of this very little software: github stars * 2) is interesting.

It seems that some keywords are more efficient than others. Let's consider this practice as social engineering.

Re:An adaptive prompt for Bash and Zsh on Sunday April 21, 2013 @06:11AM (#5584468)
That's amusing, because I've started liquidprompt for this very specific reason: I was constantly missing the battery notification icon. Time seems to have trained my brain not to look at this screen area. Fortunately, with liquidprompt alerts are spoting just where I look at, and only when necessary.
Re:An analog clock in your bash prompt on OS X on Saturday April 20, 2013 @05:09PM (#5582815)
I've proposed a PR that do just that (maybe a little bit more readable): https://github.com/paulsm/bashtime/pull/1

Also, the code is now used in the liquid prompt: https://github.com/nojhan/liquidprompt/commit/91959b636af751...