Live data from Hacker News

Colout – add colors to a text stream in your terminal

nojhan.github.io

21–30 of 41 posts

Re: Colout – add colors to a text stream in your terminal

#22
post #16

Earlier quoted context omitted.

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.).

Really? grcat/grc's configs are very simple. For example, this is the config for colorizing diffs: regexp=^\+(.*$) colours=bold green count=more ======= regexp=^\-(--.+$|[^\-].*$|$) colours=bold red count=more ======== regexp=^\>([^\>].*|$) colours=bold green count=more ======= regexp=^\ I agree that colout works better for ad-hoc stuff. You should consider inverting the way it's invoked, though, to be more like grc,…

Having just seen both utilities, colout looks very useful while grc looks like a PITA. I don't want to write configs for every adhoc command.

Re: Colout – add colors to a text stream in your terminal

#23

Earlier quoted context omitted.

Really? grcat/grc's configs are very simple. For example, this is the config for colorizing diffs: regexp=^\+(.*$) colours=bold green count=more ======= regexp=^\-(--.+$|[^\-].*$|$) colours=bold red count=more ======== regexp=^\>([^\>].*|$) colours=bold green count=more ======= regexp=^\ I agree that colout works better for ad-hoc stuff. You should consider inverting the way it's invoked, though, to be more like grc,…

Having just seen both utilities, colout looks very useful while grc looks like a PITA. I don't want to write configs for every adhoc command.

Yeah, grc is not for ad hoc utilities. It's meant to work with tools you use frequently, like make, diff, gcc, ping etc. where the syntax is known.

Re: Colout – add colors to a text stream in your terminal

#24

Earlier quoted context omitted.

Having just seen both utilities, colout looks very useful while grc looks like a PITA. I don't want to write configs for every adhoc command.

Yeah, grc is not for ad hoc utilities. It's meant to work with tools you use frequently, like make, diff, gcc, ping etc. where the syntax is known.

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

#25
post #16

Earlier quoted context omitted.

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.).

Really? grcat/grc's configs are very simple. For example, this is the config for colorizing diffs: regexp=^\+(.*$) colours=bold green count=more ======= regexp=^\-(--.+$|[^\-].*$|$) colours=bold red count=more ======== regexp=^\>([^\>].*|$) colours=bold green count=more ======= regexp=^\ I agree that colout works better for ad-hoc stuff. You should consider inverting the way it's invoked, though, to be more like grc,…

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

#27
post #26

Why did you have to switch to python3? https://github.com/nojhan/colout/commit/37934e9266d05e1519ac... https://github.com/nojhan/colout/commit/64454e42f1cf5a4f8cd4... Update: 37934e9 still works with python 2.6

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

#29
post #17
post #8

Just installed it via pip and gave it a try. I like it! I think I can already find some interesting uses for it. A couple of suggestions: The website says: colout -r will give you the lists of available colors, colormaps, themes and supported programming languages. But I think that's a typo and should be 'colout -h'. Also, a handy alias list of common use cases would be great.

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.

Hmm... when I run colout -r, I get:

   % colout -r
   usage: colout.py [-h] [-g] [-c] [-l SCALE] [-a] [-t] [-s]
                  REGEX [COLOR] [STYLE]
   colout.py: error: too few arguments

Re: Colout – add colors to a text stream in your terminal

#30
Love this. Thanks.

I can see a bunch of ways I'll make use of this. The first one I attempted to work on involved trying to color scale the use% in the output of a "df -h".

Alas it didn't work as I expected it:

    $ df -h | colout --scale 0,100 "([0-9]*)%" scale
    ValueError: could not convert string to float:
However if I grep out just the /dev/sda line it does what I expected:

    $ df -h | grep /dev/sda | colout --scale 0,100 "([0-9]*)%" scale
    /dev/sda         20G  3.2G   16G  17% /
The 17% is a pretty blue.

Tips?

Post reply on HN