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?

  • In Ubuntu ls has the --color option, and ls --color=always retains colouring when output is redirected. – AFH May 24 '16 at 17:40
  • You put me on the right track, I will make an answer for the community. – Lexib0y May 24 '16 at 18:55
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 May 24 '16 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 '16 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 '16 at 22:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.