Skip to main content
added 3 characters in body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

The problem most probably is that your ls program has set option --color to autocolor=auto which basically means that output should be coloured only if it is connected to terminal, otherwise (output connected to a pipe or a file) no colors are emitted.

If you want to have colors is such cases you should set --color option to always, so try

ls --color=always | less -R

If this behaviour is what you expect all the time then just create alias:

alias ls='ls --color=always'

The problem most probably is that your ls has set option --color to auto which basically means that output should be coloured only if it is connected to terminal, otherwise (output connected to a pipe or a file) no colors are emitted.

If you want to have colors is such cases you should set --color option to always, so try

ls --color=always | less -R

If this behaviour is what you expect all the time then just create alias:

alias ls='ls --color=always'

The problem most probably is that your ls program has set option --color=auto which basically means that output should be coloured only if it is connected to terminal, otherwise (output connected to a pipe or a file) no colors are emitted.

If you want to have colors is such cases you should set --color option to always, so try

ls --color=always | less -R

If this behaviour is what you expect all the time then just create alias:

alias ls='ls --color=always'
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

The problem most probably is that your ls has set option --color to auto which basically means that output should be coloured only if it is connected to terminal, otherwise (output connected to a pipe or a file) no colors are emitted.

If you want to have colors is such cases you should set --color option to always, so try

ls --color=always | less -R

If this behaviour is what you expect all the time then just create alias:

alias ls='ls --color=always'