
Show HN: Grep with colours written in Go - arsham
https://github.com/arsham/blush
======
abstractbeliefs
Do be sure to at least consider supporting no colour! [http://no-
color.org](http://no-color.org)

~~~
barrowclift
Genuinely curious, why do some developers prefer not having colors for ls,
grep, etc.? no-color.org mentions that many users prefer having colors
disabled, but didn't list any reasons why.

~~~
rektide
I don't find that they add anything. I feel like they make it harder for me to
do a coherent read of the screen, to suck in all the text & process it. I have
my own mental algorithms to pick out relevant things, and having a bunch of
glaringly contrasting blocks of color glaring out of the terminal at me just
makes it harder to slurp in the screen. I don't want that segmentation. It's
awful.

And the color themes for the terminal are godawful. No matter how you spin 16
colors, how solarized or other, everyone is kind of chained more or less to
that attrocious 16 color pallet, which is always going to be way way higher
contrast or low-fi than something like a vim theme that can pick some
complementary colors to work with.

Colors feel like my terminal punching me in the face. No thanks.

Also have you ever logged into ubuntu? Holy shit colors were a TERRIBLE idea.

~~~
barrowclift
That makes sense. In a way, it's like they're mental "speed bumps" that
disrupt reading the text. I can certainly see why those "bumps" would be
aggravating, thanks for the insight!

------
JackCh
Is this speed competitive with tools like _the silver searcher_ (`ag`) or is
the focus here on color?

~~~
lillesvin
As much as I love `ag`, I feel like ripgrep
([https://github.com/BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep))
deserves mentioning when it comes to speed. If you haven't tried it, do it
sooner rather than later.

Here's an excellent write-up on how it works, benchmarks, etc.:
[https://blog.burntsushi.net/ripgrep/](https://blog.burntsushi.net/ripgrep/)

~~~
VeejayRampay
ripgrep is soooooo good. I have switched to it and will never look back.

------
ereyes01
Nice job! Language-specific coloring is really nice!

I'll give it a try. I normally use a different Golang tool called sift as my
grep replacement (which I love so far):
[https://github.com/svent/sift](https://github.com/svent/sift)

Sift's goals seem to be mostly performance (it is super fast), but it would be
nice to have some of these more sophisticated coloring features in there as
well, as they are useful.

~~~
arsham
Cheers mate!

------
tex0
Nice UI! Some time ago I wrote something similar, because I was missing some
features in ripgrep (which is otherwise pretty awesome):
[https://github.com/dominikschulz/gg](https://github.com/dominikschulz/gg)

------
xab9
I like it. I started something similar with node (I never aimed for
performance) trying to go for high grep compatibility but with added extra
colors and js regexp flavour.

------
megous
GNU grep has support for colors.

~~~
kbd
Please reread the examples, which are specifying multiple searches and custom
colors for each type of match, something that GNU grep can't do.

------
teekert
But... Can it elegantly suppress broken pipe errors?

~~~
arsham
Handling signals are not implemented yet. I appreciate it if you file an issue
when you find any. Thanks.

------
grblovrflowerrr
Really cool! But from the title I initially thought this was a grep tool for
finding certain colors in your image data.

------
madmax96
Useless use of cat candidate.

~~~
dagenix
This is one of my pet peeves - complaining about technically unnecessary, but
fully benign uses of cat.

Yes, 'cat FILENAME | blush "some text"' and 'blush "some text" < FILENAME' do
the same thing. But, what if you don't have permission to read the file - the
former be re-written as 'sudo cat FILENAME | blush "some text"' \- the latter
form can't. What if you want to build a pipeline? I think its pretty
persuasive that 'cat FILENAME | blush "some text" | sort' reads better than
'blush "some text" < FILENAME | sort' \- the former reads from left-to-right,
the latter reads from the middle, to the left, and then bounces over to the
right. Tastes may very - but, I think its a hard sell that such an opinion is
clearly wrong.

So, yes, its unnecessary. And, yes, in a script using cat like that can
complicate error handling. But, for interactive use, what advice exactly are
you trying to convey?

~~~
madmax96
Sometimes things are lost over text -- my comment was meant to be more
whimsical than it actually read. Just the old
[http://porkmail.org/era/unix/award.html](http://porkmail.org/era/unix/award.html)
joke.

My actual (light) advice is merely that we're all guilty of inappropriately
using IO redirection facilities that punish the performance of our shells.
`cat <filename> | grep <expression>` should be replaced by `grep <expression>
<filename>`.

No doubt that pipelines are easier to read. The author has a whole section in
README demonstrating blush's ability to read STDIN - nothing is lost by using
best practices everywhere else. Documentation matters, and it should
communicate best practices.

