2

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?

2
  • In Ubuntu ls has the --color option, and ls --color=always retains colouring when output is redirected.
    – AFH
    May 24, 2016 at 17:40
  • You put me on the right track, I will make an answer for the community.
    – Lexib0y
    May 24, 2016 at 18:55

1 Answer 1

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.

3
  • 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
    May 24, 2016 at 19:54
  • Should I add the FreeBSD tag to the question? It might work on other systems... They question and answer should be clear enough.
    – Lexib0y
    May 24, 2016 at 21:31
  • 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
    May 24, 2016 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .