I'm coming from StackOverflow where I posted this question and got redirected here. Let me ask it here again :

I have been trying to add colors to my mac terminal but not every file is colored. Furthermore different files with the same extension (ex : .png) show some particular behaviour : some of them are colored, and some of them are not.

I have been following different tutorials around the web (installing coreutils, and using CLICOLOR=1). Both gave the same result, some files are colored, some are not.

Here is what I wrote in .bash_profile following a thread like this one:

export CLICOLOR=1
export LSCOLORS=ExGxFxdxCxDxDxHBhDhCgC

I then saved, forced reload with source .bash_profile and launched a new terminal window. Here is what it gave me (3 png images that are not color coded the same way).

It also will not work with other extensions (eg. zip here). Directories (in purple) seem to be the only "type" color coded every time.

Note : I generally use iTerm2 but both terminals have the same behavior.
Note : The screenshots are the same if I write ls -G instead of ls.

I have searched everywhere and cannot find someone who asked the same question online. Hopefully you can help me! Thank you!

EDIT : Here's what happens when I write ls -linstead of ls as Kamil Maciorowski asked in commments (I did not know that was what they asked and I do not know if it helps).


You can use this LSCOLORS generator to preview and play with the colors and to get a better understanding of what colors are applied to what items.

As the users on Stack Overflow already mentioned, your files have different permissions. In the case of the PNG images, two of them have the x (execute) permission, while the third does not.

The first column of the output of ls -l is the permissions.

-rw-r--r--@ 1 wexus  staff  512458 Jul 10  2018 jetpack.png
-rwxr-xr-x@ 1 wexus  staff  442020 Mar 11  2015 scribd.png
-rwxr-xr-x@ 1 wexus  staff  297118 May 19  2015 ulule.png

You can change permissions using the chmod command.

LSCOLORS follows the order listed in the answer to your Stack Overflow question:

  1. directory
  2. symbolic link
  3. socket
  4. pipe
  5. executable
  6. block special
  7. character special
  8. executable with setuid bit set
  9. executable with setgid bit set
  10. directory writable to others, with sticky bit
  11. directory writable to others, without sticky bit

As you can see, regular files aren't included here, so they (I believe) will use the default formatting. If you want to have files with the x permission shown the same as other files, you should apply Xx or xx as the 5th block. Capitalizing the first letter will make the text bold.


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.