Live data from Hacker News

Show HN: Grep with colours written in Go

github.com

21–30 of 90 posts

Re: Show HN: Grep with colours written in Go

#21

Do be sure to at least consider supporting no colour! http://no-color.org

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.

My terminal has non-default long-battle-tested background and foreground colors, and I barely pay an attention to the entire palette, so coloring works like acid. Some colors are simply incompatible, so tuning them is meaningless. Imagine e.g. any dark blue on medium grey.

What I think would be good (for me at least) is not colors, but sort of markup, like bold or underline, which is available in terminal as seen in man pages and PS1. I usually make them bold and compatible colored.

Re: Show HN: Grep with colours written in Go

#22

Do be sure to at least consider supporting no colour! http://no-color.org

I don't understand why this is a standard.

First: It requires that every command line tool add support for this environment variable. It may not be much effort for each project, but it adds up to a ton of developer time. Even if this standard gains traction, some apps will slip through the cracks. So in the success case, many users will still be annoyed that one or two of their tools print colors when they shouldn't.

Second: As the FAQ on that page mentions, people can configure their terminal emulators to squelch color. NO_COLOR only matters for users who want color in some applications and not others. In that case, are certain applications supposed to refuse supporting NO_COLOR? Will all users want the same set of programs to behave that way? Are users supposed to unset NO_COLOR before running those programs?

At that point, it seems like a more complex version of using some aliases that add --color=never (or whatever the appropriate flag is). Or if the user prefers to disable color by default, they could set $TERM to "xterm-old" and alias their favorite commands to add --color=always. Either way, there's no need for another environment variable.

Really though, this seems like it should be a feature of the shell or the terminal emulator. Does the process name match certain patterns? Pass color codes through. No? Strip them. That would solve the problem for all programs past, present, and future. And total development effort would likely be less than that needed to implement NO_COLORS in every command line tool.

Re: Show HN: Grep with colours written in Go

#23

Earlier quoted context omitted.

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.

My guess is the ansi color escape codes mess with peoples parsing code of the output when scripting.

All sane tools check if output isatty(3) before doing that.

Re: Show HN: Grep with colours written in Go

#24
post #22

Do be sure to at least consider supporting no colour! http://no-color.org

I don't understand why this is a standard. First: It requires that every command line tool add support for this environment variable. It may not be much effort for each project, but it adds up to a ton of developer time. Even if this standard gains traction, some apps will slip through the cracks. So in the success case, many users will still be annoyed that one or two of their tools print colors when they shouldn't.…

I'll speak for my case specifically: a lot of programs I use have varying levels of colour-by-default, but I don't want that. What I want is to have them all off, except the ones that actually add value.

I think it's apparent that this isn't something you're really keen to support in ag in the few times I've seen you talk about it, so feel free to close the PR I have open there rather than leave it hanging without any reply.

https://github.com/ggreer/the_silver_searcher/pull/1207

Re: Show HN: Grep with colours written in Go

#25
post #23

Earlier quoted context omitted.

My guess is the ansi color escape codes mess with peoples parsing code of the output when scripting.

All sane tools check if output isatty(3) before doing that.

Many don't though. Typically, though, the place to add no-color is even on the same line as this test and is a very cheap add, so anyone looking to add it would do well to consider adding both.

Re: Show HN: Grep with colours written in Go

#26
post #22

Do be sure to at least consider supporting no colour! http://no-color.org

I don't understand why this is a standard. First: It requires that every command line tool add support for this environment variable. It may not be much effort for each project, but it adds up to a ton of developer time. Even if this standard gains traction, some apps will slip through the cracks. So in the success case, many users will still be annoyed that one or two of their tools print colors when they shouldn't.…

What if someone needs colors, but not colors that util maker used? What if two or more tools make different use of colors? With terminal aware of that problem you can remap or erase specific colors, but maybe it’s wiser to not create a problem at all, since just making text bold may be enough for practical needs.

Edit: missing not

Re: Show HN: Grep with colours written in Go

#27
post #23

Earlier quoted context omitted.

All sane tools check if output isatty(3) before doing that.

Many don't though. Typically, though, the place to add no-color is even on the same line as this test and is a very cheap add, so anyone looking to add it would do well to consider adding both.

Many who? Did I miss the arrival of new “Move Fast Etc” era into unix cli?

Re: Show HN: Grep with colours written in Go

#28
post #27

Earlier quoted context omitted.

Many don't though. Typically, though, the place to add no-color is even on the same line as this test and is a very cheap add, so anyone looking to add it would do well to consider adding both.

Many who? Did I miss the arrival of new “Move Fast Etc” era into unix cli?

There's a bunch even on that list. I had a look at ffind, the second on the page and found nothing to test if the output was tty or otherwise.

Generally though, I'm not out to point fingers, it's just a fact that not all software is complete and bug-free. We're all people with limited time and we don't have the attention to detail that dealing with the maliciously compliant children that computers are takes.

Re: Show HN: Grep with colours written in Go

#30
post #18

Earlier quoted context omitted.

Ummm...your kidding right? I know ripgrep has a ton of fantastic optimizations by Burntsushi. You might wanna check it out...before making such statements.

I could be wrong, but I read valarauca1's comment as "I’m doubtful. ag and rg use a lot of smart optimizations to get their speed."

lol people's reading comprensión is so bad sometimes
Post reply on HN