ripgrep: --color does not work under Emacs
I’m using rg 0.2.1 and Emacs 25. It looks like --color doesn’t have effect under Emacs, while other tools such as grep works.
M-! echo hello | grep --color=always hellogives[01;31m[Khello[m[KM-! echo hello | rg --color=always hellogiveshello(where is the escape code?)
see also https://github.com/emacs-helm/helm/issues/1624#issuecomment-253879188
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 28 (17 by maintainers)
Commits related to this issue
- Completely re-work colored output and tty handling. This commit completely guts all of the color handling code and replaces most of it with two new crates: wincolor and termcolor. wincolor provides a... — committed to BurntSushi/ripgrep by BurntSushi 8 years ago
- Use basic SGR sequences when possible. In Emacs, its terminal apparently doesn't support "extended" sets of foreground/background colors. Unless we need to set an "intense" color, we should instead u... — committed to BurntSushi/ripgrep by BurntSushi 7 years ago
Andrew Gallant notifications@github.com writes:
I installed rust and builded rg from master, and I can confirm rg is now outputing colors as expected 😃.
Many thanks for your quick fix and for rg!
– Thierry
Andrew Gallant notifications@github.com writes:
There is no hurry, thanks for all your explanations and sorry to not be able to help on this, my knowledge about all this is limited.
Ok, we will use
TERM=eterm-coloras a workaround for now.Thanks again for your help on this.
Thierry
@thierryvolpiatto @xuchunyang I think the bottom line here is that while
ripgrepis technically respecting the letter of the law, it doesn’t actually match up with user expectations and that’s bad. That means I agree we should do something here, but the right answer might take a bit of time to happen. For now, I’d request settingTERMto something that makesripgrepwork as a temporary work-around. Hopefully that’s feasible to do.At least GNU grep hard codes ANSI color escape sequences and AFAIK doesn’t actually respect the
TERMINFOdatabase. e.g.,ripgrepisn’t failing as far as I can see, it’s simply respecting what the environment is saying, while all of the other tools aren’t.What is the correct behavior here? If
TERM=dumbis set and--color=alwaysis set, then how doesripgrepknow whichTERMsettings to use? Should it forcefully pick aTERMother thandumb? Which one?