3

So I followed this thread (Changing terminal color) and got all of the colors working for directories and such, except however, for normal files such as a Gemfile or .txt files or .java files or .rb files etc... I was wondering how I can get normal files to show up in color, even better if I can get different extensions of the file to show up in different colors as well. Let me know if you guys have any resources for this.

  • 2
    This is a nice guide, though I'm not sure as to whether it changes file as well as directory color (screenshot only shows top level traverse). – njboot Jun 9 '14 at 19:28
1

I don't think colorizing the file names of regular files is possible with ls alone (i.e. without postprocessing the output with another script):

  1. The manual page for ls (shown when you type man ls) does not mention this possibility.

  2. I would expect that the ls coming with Mac OS X is very similar to the BSD version of ls, since there seems to be little motivation for Apple to make changes in this area. The source code for BSD's ls is available online, e.g. the FreeBSD version is on GitHub. The function which selects the color for a file name is colortype() in the source file bin/ls/print.c. And checking the source code it is clear that at least the BSD version of ls does not have the ability to change color when printing the names of a regular file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .