Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can you make a bash shell list executable files in a different color than non-executable files?

I've tried editing ~/.bashrc to contain the following line (it's otherwise empty):


But it's not working. What am I doing wrong? I'm working on Mac OS X.

share|improve this question

On the Mac, you need to use

export CLICOLOR=1

I put that in the .bash_profile. However, I prefer Rich Homolka's solution to alias ls with -G flag. If you want to customize the colors:

man ls

and search for LSCOLORS

share|improve this answer

To turn on colour output from the ls command without having to create an alias to ls or download any additional software, add the following to your ~/.bash_profile:

# Terminal colours
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

If you don't like those colours you can use this ls color generator to customize that color list to your liking.

You'll need to do:

source ~/.bash_profile

After making any changes for them to take effect in your existing shell.

share|improve this answer
no, it doesn't help at all – holms Nov 16 '13 at 3:24

The problem is that OS X doesn't have GNU ls; while its ls does support file name coloring, it can only do so by the type of file (file, directory, symlink, device special file, fifo, socket...). Install coreutils from Fink/MacPorts/HomeBrew, then use alias ls='gls --color=auto'.

share|improve this answer
Thanks. I've installed coreutils from MacPorts. Should the alias line be in ~/.bashrc? That's where I've put it, but I'm not seeing any difference. – AP257 Mar 22 '11 at 23:10
~/.bash_aliases may work better. I also found that I needed to run eval $(gdircolors -s) to set it up. – geekosaur Mar 22 '11 at 23:12
@AP257: On my Mac, I put aliases into the .bash_profile – Hai Vu Mar 29 '11 at 2:56
@Hai Vu: That only works if you never use subshells. – geekosaur Mar 29 '11 at 2:58
@geekosaur gdircolors: invalid option -- 's' do you mean --sh ? – Anentropic Jan 15 '13 at 12:44

BSD ls works a bit differently

alias ls='ls -G'

should work.

And this isn't bash coloring, it is ls doing the colorization. When bash does a file list (try echo * in a directory) there is no way to colorize. Typing ls -G would work in any shell, though a shell (like bash) that has aliases makes it easier.

share|improve this answer

bash is only a shell, it does not list files. It executes commands, such as ls.

The --color option (and long options in general) is specific to the version of ls from GNU coreutils, which comes with most Linux distributions. On the other hand, Mac OS X has BSD roots and uses the BSD version of ls which does not support colouring.

share|improve this answer
-1: It does support colouring, just with a different command-line flag: -G. – Wuffers Mar 29 '11 at 2:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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