7

ls -l gives me color coded output. Folders are blue, executables green, etc. These colors are gone when filtering thorough | more. Anyway to achieve both paged output and colors?

1
  • Can you give us a detailed explanation?
    – Random Guy
    Oct 5, 2011 at 11:21

3 Answers 3

7

Try with less command with repaint(-R) option:

ls --color=always -l | less -R
7
  • That works, and actually more as pager also works. Oct 5, 2011 at 11:29
  • 1
    Shouldn't it be -R (only change is uppercase R)? See here for why... Oct 5, 2011 at 11:37
  • @Breakthrough: +1. i'll update it. Oct 5, 2011 at 11:39
  • 3
    Actually it also works with more with the --color=always, so that was the key for me!
    – Nilzor
    Oct 7, 2011 at 8:11
  • 1
    Unfortunately this doesn't work for Mac OS X / BSD, but is fine for Linux Dec 4, 2014 at 17:53
2

Try:

ls -lA --color=always | more
1

Search for the term "escape sequence" in the man page of less. About the colorful stuff, see ANSI escape code # Colors;

There is a detailed solution on askubuntu.com on how to have paged & colored output; the key info is:

ls -C --color=always | less -R

You must log in to answer this question.

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