49

I don't want an alias (alias ls='ls --color'), and I had previously set this up on Mac OSX using CLICOLOR environment variable which magically brought colors to ls. Now I am on Linux (Arch x86-64) with xterm and a really basic setup, and I can't make ls output color (using ls verbatim). I do get color when using --color switch.

Is there no way to achieve this? POSIX compliance would be nice :-)

73

There is no way: the ls man page will show you that the default setting (for --color) is 'none' - ie. never use colour.

Any reason you don't want to use aliases? I'm a recovering Red Hat user, so every time I install a new distribution I set three ls aliases like so:

## Colorize the ls output ##
alias ls='ls --color=auto'

## Use a long listing format ##
alias ll='ls -la'

## Show hidden files ##
alias l.='ls -d .* --color=auto'
|improve this answer|||||
  • 2
    No reason I cannot - I was on Mac OSX the other day, and it supported the CLICOLOR which I thought was kind of standard (you always tend to think that these things are standard). And I also always thought of aliases as more of an retrofit solution. But they'll do just fine :-) – amn Oct 28 '13 at 10:25
  • 17
    On Mac OSX you can use alias ls='ls -G' – Gal Bracha Aug 6 '17 at 13:44
  • 3
    also add alias grep='grep --color' to it ;) – AmirHossein Jul 7 '18 at 4:46
  • Put them together like so alias ll='ls -la --color=auto' – HackSlash Nov 5 '19 at 17:01
-3

if using the -F option --color is unnecessary, for instance alias ll='ls -alF' shows colors

|improve this answer|||||
  • 3
    This is incorrect. – Scott Nov 24 '18 at 23:49
  • One can use \ls -alF to test the original ls command and not be confused with an option set elsewhere. – Biggybi Jan 28 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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