1
I am using FreeBSD with the csh shell. As an example, in the terminal / screen I get color output for ls (eg. ls -lGs). But when I pipe it through more (eg ls -lGs | more) the output has no colour. Is there a way to have more also display color?
1
I am using FreeBSD with the csh shell. As an example, in the terminal / screen I get color output for ls (eg. ls -lGs). But when I pipe it through more (eg ls -lGs | more) the output has no colour. Is there a way to have more also display color?
1
I solved the problem in two steps.
First I set the environment varable CLICOLOR_FORCE in .cshrc to force output other then to TERM to also use colors, eg:
CLICOLOR_FORCE 1
more has a command line option -R to output color sequences.
-R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screen appearance is maintained cor- rectly in most cases. ANSI "color" escape sequences are sequences of the form:
These two combined gave me the desired results, so
ls -lGs | more -R
now displays the output in color.
Glad you found a solution: for the record, your answer doesn't work with my configuration of Ubuntu/bash
with GNU ls
, but this is a long way from FreeBSD/csh
, so it's not surprising. In my case more
has no -R
option, but it works without. – AFH – 2016-05-24T19:54:14.177
Should I add the FreeBSD tag to the question? It might work on other systems... They question and answer should be clear enough. – Lexib0y – 2016-05-24T21:31:29.760
I'm not sure what to advise: I have seen reference to CLICOLOR_FORCE
on other systems, and my comments should help when your solution doesn't work. I have no idea how many people will come upon this solution by searching on the tag, rather than the title, but I suspect not many. – AFH – 2016-05-24T22:15:37.980
In Ubuntu
ls
has the--color
option, andls --color=always
retains colouring when output is redirected. – AFH – 2016-05-24T17:40:11.370You put me on the right track, I will make an answer for the community. – Lexib0y – 2016-05-24T18:55:39.610