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

On my linux machine, you can tell intact symlinks from broken ones, because broken ones are colored red. I've tried to set this up on my mac by adding some configurations to PSCOLORS in my .bash_profile, but so far nothing has worked. I've managed to get the coloring to tell apart directories, files, executables, and symlinks. However, the broken symlinks are not a different color than intact symlinks. Searching around on google hasn't rendered any promising results. Ideas? Tricks?

share|improve this question
You might be successful in installing a port of Linux' ls that supports coloring symbolic links for their targets, and colors orphaned links. OS X's ls simply cannot do it. It's 150KB of source code vs. 25KB of source code... – Daniel Beck May 18 '12 at 9:41
up vote 5 down vote accepted

I don't think it's possible – the man page for ls doesn't list a color slot for broken symlinks.

Here's a handy find one-liner for finding broken symlinks:

find -L . -type l -ls
share|improve this answer

Use Homebrew and install GNU coretuils. Make sure you are using GNU ls.

Put the following in ~/.bash_profile:

export LS_COLORS

Open a new shell, and broken links will be highlighted like on Linux.

The LS_COLORS environment is specific to GNU ls. The code is a verbatim copy of the output of dircolors command on Ubuntu 12.04.

share|improve this answer
don't forget to add the following alias in your ~/.bash_profile: alias ls="gls --color=auto" – lorenzo Oct 31 '14 at 14:43

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.