Better HN
topnewbestaskshowjobs
Log inSign up

nojhan

183 karma · joined Jul 19, 2012 (14y ago) · 21 submissions

Submissions

1.

An elegant and readable Game of Life implemented in python(github.com ↗)

3 points · by nojhan · 11y ago · discuss

2.

Simple and elegant declaration and localization of exceptions in C++(github.com ↗)

1 points · by nojhan · 12y ago · discuss

3.

Best way to implement functors: inheritance VS CRTP?(github.com ↗)

1 points · by nojhan · 12y ago · discuss

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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?

comment 13y ago · link · parent

You can, it's just a matter of knowing how to write a function for your shell.

comment 13y ago · link · parent

It should not be too difficult to use the same config files in colout, btw.

comment 13y ago · link · parent

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.

comment 13y ago · link · parent

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

14.

Colout – add colors to a text stream in your terminal(nojhan.github.io ↗)

116 points · by nojhan · 13y ago · 40 comments

comment 13y ago · link · parent

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.

comment 13y ago · link · parent

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.

17.

An adaptive prompt for Bash and Zsh(github.com ↗)

68 points · by nojhan · 13y ago · 21 comments

comment 13y ago · link · parent

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

19.

Rethinking the command line prompt(github.com ↗)

3 points · by nojhan · 13y ago · discuss

20.

Liquid prompt — A useful adaptive Bash prompt(github.com ↗)

2 points · by nojhan · 14y ago · discuss